Alexey I. Froloff wrote:
* Bram Moolenaar <Bram@> [060831 00:14]:
The current method is correct. In the ftdetect scripts you can check
for 'filetype' being equal to "conf" and then do ":set ft=anything" to
overrule it. Use ":setf" only when you don't want to overrule the
default filetype.
I want these files act as "default" and I don't want to patch
filetype.vim. Will :setf work after :set filetype ?
":setf bar" will not work after ":set filetype=foo", neither will it
work after ":setfiletype foo"; it will (IIUC) work after ":set
filetype=" (setting it forcibly to empty). But if you want your settings
to act as defaults, you can use the ":setf" command -- anything else
will already have been detected. Filetype "conf" itself is only set
after all other tests (except ftdetect/*.vim) have been run, be they
defined by Vim in $VIMRUNTIME/filetype.vim, by the sysadmin in
$VIM/vimfiles/filetype.vim (which is run before that) or by the
individual user in ~/.vim/filetype.vim (which is run before them both).
Or you may use the following in ftdetect/*.vim
if &ft == "" || &ft == "conf"
set filetype=blahblahblah
endif
if you want to override "conf" filetype but leave any other nonempty
filetype unchanged.
If I misunderstood, please be more specific: do you or don't you want to
override the filetype detected by filetype.vim ? If you do, use ":set
filetype=something". If you don't, use the ":setf" command. If sometimes
you do and other times you don't, you must ascertain which is which.
You should not patch $VIMRUNTIME/filetype.vim, but you can set up a
$VIM/vimfiles/filetype.vim (to be sourced before it) or a
$VIM/vimfiles/after/filetype.vim (to be sourced after it, and after
ftdetect/*.vim). Don't set did_load_filetypes yourself if you want the
default mechanism to run.
Best regards,
Tony.