I had the same problem when I started using vim. The solution is simple, you just need to edit the c syntax file used by vim, here's how to do it:
When you start editing a C or C ++ file, vim reads the default c syntax file located at
$VIMRUNTIME/syntax/c.vim
(Where $ VIMRUNTIME is where you installed vim. You can find out its default value by opening vim and using the command:: echo $ VIMRUNTIME).
You can simply overwrite this file or create your own C syntax file (which will be loaded by vim instead of the default file) in this place:
$HOME/.vim/syntax/c.vim (for UNIX) $HOME/vimfiles/syntax/c.vim (for PC or OS/2)
(I never used a Mac, so I donβt know which one will work for you. You can find out more in the vim help: "help vimfiles")
Now the fun part. Copy the default file "$ VIMRUNTIME / syntax / c.vim" to the vimfiles directory ("$ HOME / .vim / syntax / c.vim" for UNIX) and edit it by adding the following lines:
" Highlight Class and Function names syn match cCustomParen "(" contains=cParen,cCppParen syn match cCustomFunc "\w\+\s*(" contains=cCustomParen syn match cCustomScope "::" syn match cCustomClass "\w\+\s*::" contains=cCustomScope hi def link cCustomFunc Function hi def link cCustomClass Function
It! Now the names of functions and classes will be highlighted with the color defined in the selection "Function" (": hi Function"). If you want to customize the colors, you can change the last two lines above to something like this:
hi def cCustomFunc gui=bold guifg=yellowgreen hi def cCustomClass gui=reverse guifg=
or you can leave the C syntax file alone and define the colors in your vimrc file (": help vimrc"):
hi cCustomFunc gui=bold guifg=yellowgreen hi cCustomClass gui=reverse guifg=
(Note the lack of the def keyword, go to ": help highlight-default" for more information). For available options for the ": hi" command, see ": help: highlight".
You can find the full c.vim file for Vim 7.2 at this link (Note: use it only if you have unmodified Vim version 7.2):
http://pastebin.com/f33aeab77
And a required screenshot:
