DM wrote:
Hi,

I'm using gVim on windows. I've created an lzx.vim syntax file and dropped it 
into C:\Program Files\Vim\vim70\syntax.
It works fine if I execute:

:cal setSyn("lzx")


However this syntax is not available from the syntax menu and vim does not 
automatically use this syntax when I open files with an .lzx extension.
How can I fix these problems?


Thanks in advance,
Don

1. Don't drop anything into $VIMRUNTIME and its subdirs, it may be silently erased at any upgrade and it _will_ be forgotten when you upgrade to Vim 7.1 (which is already out by now). Drop that script into $HOME/vimfiles/syntax/ or $VIM/vimfiles/syntax/ (this is in Vim notation; the latter corresponds e.g. to "C:\Program Files\vim\vimfiles\syntax"), and create the necessary directories if they don't yet exist. $VIMRUNTIME, and everything under it, is ONLY for files distributed together with Vim. Putting anything else there is courting disaster.

2. You have to tell Vim to recognise that syntax. Normally each syntax corresponds to a filetype. So, create a file named $HOME/vimfiles/filetype.vim or $VIM/vimfiles/filetype.vim and paste the following into it:

augroup filetypedetect
        autocmd BufRead,BufNewFile *.lzx setfiletype lzx
        " for every future «new» filetype, add one autocommand here
augroup END

If that file already exists, it already ought to have the "augroup" commands at beginning and end, so in that case you need only paste the "autocmd" line in the middle.


With the above, Vim will recognise all *.lzx files as of filetype "lzx", and, thanks to an already existing autocommand, all files of "lzx" filetype will get "lzx" syntax and source your syntax script. (You must of course, have filetype detection on, but I assume you already have that.)


After you do the above, and restart Vim, the new syntax ought to appear in the menu.


Best regards,
Tony.
--
"There is a God, but He drinks"
                -- Blore

Reply via email to