Friday, June 18, 2010

Re: set filetype in .vimrc

On 19/06/10 01:17, aleCodd wrote:
>
> i have the following in .vimrc:
> au BufNewFile,BufRead *diff*.txt set ft=diff_help
> but then when i do
> tabnew diff.txt
> set ft
> i get
> filetype=help
>
> why?
>
> by the way, i have later on in .vimrc
> filetype on
> does this override the autocommand?
>
> because from insdie the buffer when i set a help type file (*.txt) manually
> to anything (for exapmle:'new') and then the command filetype, the filetype
> doesn't changed
>
> thanks
> alex
>
>

Most Vim helpfiles have a modeline at the end, something like

vim:tw=78:ts=8:ft=help:norl:

(see :help modeline)

The :ft=help: part in such a modeline (intentionally) overrides any
filetype which might have been set by the filetype-detection mechanism.
Normally you wouldn't want to override such modelines, they're there for
good reason. (For instance I have an own-coded rule to identify *.txt
files as filetype "text", but thanks to these modelines it doesn't apply
to the Vim help.)


Best regards,
Tony.
--
Hackers do it with all sorts of characters.

--
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: