That looks all right. Do you have any ":set" command for the
'runtimepath' (or 'rtp') option in your vimrc?
When you use ":e filename" to open a file of a different filetype, it
does get highlighted, doesn't it?
Best regards,
Tony.
--
TALL KNIGHT OF NI: Ni!
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD
Hmm -- au! clears autocmds from the containing augroup. Perhaps you
should try
...
augroup filetypedetect
au BufRead,BufNewFile *.nc setfiletype nesc
augroup END
Regards,
Chip Campbell
> I didn't set any 'runtimepath' or 'rtp' option. And it does get
> hightlighted when opening other type files.
Please bottom-post, DragonKeeper, particularly if somebody already has,
or things get very confusing (posting guidelines are here:
http://groups.google.com/group/vim_use/web/vim-information
).
It is correct that you probably don't want the bang (!) on your
autocommand, but I doubt that will cause the problem.
You can check both autocommand events have been registered in Vim with
:au * *.nc
Assuming this shows two entries as expected, each saying setfiletype
nesc, I suspect the problem is not the autocommand but something in the
highlighting script. Could you share that (presumably nesc.vim)?
Another thing you can do to see what's going on is do
:set verbose=2 " or 10 or 15 for more details
:e whatever.nc
:set verbose=0
and see if that helps track things down.
Ben.
Please write your replies under a short-relevant quote like I am doing.
This is called 'bottom-posting' and is the convention on this mailing
list.
> I use ":au * *.nc" to check autocommand events, but there is nothing.
OK. So something has gone wrong with registering the autocommand.
The snippet you had for 'filetype.vim' should be in ~/.vim/filetype.vim:
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.nc setfiletype nesc
augroup END
You also need to have
:filetype on
:syntax enable
or something similar to that in your ~/.vimrc.
Make sure you have both those things, and then check that if you do
:au * *.nc
then indeed you do get two commands listed. Until that is sorted out, it
won't work.
> After that, I set the verbose and the following is the output:
Your results are consistent with the autocommand not being registered.
> BTW, I didn't write the nesc.vim by myself. the script coming with
> TinyOS is:
>
> 1 " Install this file to ~/.vim/syntax/nesc.vim.
>
> I installed it in ~/.vim/plugin/nesc.vim.
You need to install it in ~/.vim/syntax/nesc.vim like it says. Note
'syntax' not 'plugin'. You may need to create that directory. That
explains why it works when Vim starts up (which is when it reads
plugins) but not for other files (when it detects filetypes and loads
syntax).
Ben.