很简单的东西,竟然没有人来做。之前虽然没有高亮,但也没出什么问题,于是我忍了。可今天,我要在 HTML 模板里用小于号了,于是 Vim 给我高亮成错误。于是我就做了:
" Vim syntax file " FileType: Tornado template " Author: lilydjwg <lilydjwg@gmail.com> " Add something like the following in modeline to your templates: " {# vim:se syntax=html.tornadotmpl: #} syntax region tmplCode matchgroup=PreProc start="{[%{]!\@!" end="[%}]}" contains=@Python,tmplKeyword containedin=ALL syntax region tmplComment matchgroup=PreProc start="{#!\@!" end="#}" syntax region tmplComment matchgroup=PreProc start="{%\s\+comment\s\+" end="%}" syntax keyword tmplKeyword end include apply autoescape block extends module raw set let b:current_syntax_save = b:current_syntax unlet b:current_syntax syntax include @Python syntax/python.vim let b:current_syntax = b:current_syntax_save unlet b:current_syntax_save highlight link tmplCode Normal highlight link tmplComment Comment highlight link tmplKeyword Keyword
此文件可从 vim.org 下载(记得要评分哦),将其放入~/.vim/syntax即完成安装。使用方法很简单,比如 HTML 模板就写set syntax=html.tornadotmpl,JavaScript 的就写成set syntax=javascript.tornadotmpl。可以按注释里那样子写到模式行里去。详见手册:help 'syntax'。






