Sunday, September 30, 2012

Re: Prolog filetype problem

On Sunday, September 30, 2012 4:07:41 PM UTC-5, Gautier DI FOLCO wrote:
> Hi all,
>
> I write some code in Prolog and some code in Perl, the problem is that these
> two languages have the same extension, is their a mean to set the good
> filetype not according to their extension, but according to the language
>
> highlighting that find the most tokens?
>

It looks like Vim will automatically detect prolog rather than Perl if the first non-blank line contains any of:

1. the word "prolog"
2. a prolog comment, % or /* ... */
3. the prolog :- construct

Otherwise, Vim detects Perl. So for existing files, just get into the habit of starting the file with a header comment and you'll be fine.

I guess new files will always detect as Perl, but there's really not any way I can think of for Vim to detect in a general way what filetype a brand-new empty file should be. You could set up some BufNewFile autocmds based on project directory or something if you like for this.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: