How to easily add syntax highlighting for custom DSL into Vim
I am wondering how to conveniently add a custom DSL syntax highlighting into VIM. Is there any good tutorial on this topic any开发者_如何学Cwhere?
The vim wiki on wikia has a nice tutorial about the creation of syntax files
http://vim.wikia.com/wiki/Creating_your_own_syntax_files
I am not sure there are tutorials available but the basic steps are :
- Read
:help syntax
from Vim, all of it, to understand how syntax highlighting work in Vim - Have a look at existing syntax file in $VIMRUNTIME\syntax, identifying the language closest of what you want. By adapting an existing file, you won't have to rewrite everything from scratch.
- Create your own syntax file (+ file type) this will probably takes you some time.
- Add the following line to your .vimrc to use your newly created file type:
au BufNewFile,BufRead *.newtype set filetype=newtype
Alternatively, if your language is somewhat popular, there is a good chance that someone else has already written a language.vim
. If it is not available from vim.org you can search on github.
精彩评论