LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 956|回复: 2

how to hightlight a kind of special filetype docs in vim

[复制链接]
发表于 2006-11-9 23:35:40 | 显示全部楼层 |阅读模式
suppose the filetype is en. Then, write a file
~/.vim/syntax/en.vim with contents as follows:
syn case ignore
syn region enIdentifier start=/`/ end=/`/
syn region enString start=/"/ end=/"/
syn region enType start=/</ end=/>/
syn region enUnderlined start=/|/ end=/|/
syn sync minlines=10
syn case match

hi def link enIdentifier        Identifier
hi def link enString    String
hi def link enType              Type
hi def link enUnderlined Underlined
let b:current_syntax = "en"
----------- end of en.vim ---------------

we also need another file
~/.vim/filetype.vim :

        augroup filetypedetect
        au BufNewFile,BufRead *.en      setf en
        augroup END
----------- end of filetype.vim ---------

more helps refer to these:
:h hightlight
:h syntax
:h usr_44.txt

enjoy!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
 楼主| 发表于 2006-11-10 11:02:16 | 显示全部楼层
Maybe it should be better in this way:

syn case ignore
syn region enConstant start=/</hs=e+1 end=/>/he=s-1
syn region enType start=/`/hs=e+1 end=/`/he=s-1
syn region enString start=/|/hs=e+1 end=/|/he=s-1
syn region enTodo start=/@/hs=e+1 end=/@/he=s-1
syn sync minlines=10
syn case match

hi def link enConstant         Constant
hi def link enString        String
hi def link enType                 Type
hi def link enTodo                 Todo
let b:current_syntax = "en"
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-11-10 12:06:14 | 显示全部楼层
syn region enConstant start=/</hs=e+1 end=/>/he=s-1 contains=ALL keepend
syn region enType start=/`/hs=e+1 end=/`/he=s-1 contains=ALL keepend
syn region enStatement start=/|/hs=e+1 end=/|/he=s-1 contains=ALL keepend
syn region enTodo start=/@/hs=e+1 end=/@/he=s-1 contains=ALL keepend
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表