Very simple vim syntax file

576 Views Asked by At

I want to create a very simple vim syntax file that only highlights specific keywords

I saved a file called coffee.vim in ~/.vim/syntax/

the file has syn keyword basicLanguageKeywords if then for in of do in it

Am I on the right track?

Where do I go from here to actually use that simple vim syntax file?

1

There are 1 best solutions below

0
On

You're nearly there. You need to specify the colouring of the basicLanguageKeywords type with a line such as:

 hi def link basicLanguageKeywords   Conditional

(this tells the current colourscheme what to do with the keywords). Then, you can tell Vim to use this syntax by setting the filetype:

 setlocal filetype=coffee

That should be all that's needed. If you want all files ending in .coffee to use this syntax file you can add something like

 autocmd BufRead,BufNewFile *.coffee setlocal filetype=coffee

to your .vimrc.

Hope this helps.