开发者

Adding custom highlighting for project's API function names in Vim

How can I add new function names for .c and .h files to be highlighted, similar to this Customizing Syntax Highlighting in Vim but much easier? (as I don't need to color words in d开发者_JS百科ifferent colors, only in the default color for keywords as defined by my theme).

I need this to add highlighting for function names in a project written in C which has a clearly defined API.

Thanks


Try putting this in ~/.vim/after/syntax/c.vim:

syn keyword Keyword func_name1 func_name2 func_name3

you can see the defined highlight groups with:

:highlight

if you want to pick your colors:

syn keyword Myfunctions func_name1 func_name2
highlight Myfunctions guifg=red

assuming you use the GUI version and you like red, check :help highlight for details.

If you want to keep this particular highlight local to a project instead of applying it to every C file, you can add this to your .vimrc

au BufNewFile,BufRead *my_project/* source ~/.vim/myproject_syntax.vim

of course the path and the name and location of the syntax file are totally free.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜