Very simple vim syntax file

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

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

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

Am I on the right track?

Where can I go from here to use this simple vim syntax file?

+4
source share
1 answer

You are almost there. You need to specify a coloring of type basicLanguageKeywords with a string, for example:

  hi def link basicLanguageKeywords Conditional 

(this tells the current color scheme what to do with the keywords). You can then tell Vim to use this syntax by setting filetype:

  setlocal filetype=coffee 

That should be all that is needed. If you want all files ending with. Coffee, used this syntax file, you can add something like

  autocmd BufRead,BufNewFile *.coffee setlocal filetype=coffee 

to your .vimrc.

Hope this helps.

+5
source

Source: https://habr.com/ru/post/1339560/


All Articles