I'm trying to highlight the keywords for my c++ project.
So what I've done is to create a file here:
~/.vim/after/syntax/cpp.vim and put some custom configuration into it.
For example, putting the lines as below can highlight the class name:
hi CustomClassName guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=lightgreen ctermbg=NONE cterm=bold syn match cCustomClassName "\(^class\s*\)\@<=\w\+" hi def link cCustomClassName CustomClassName
As you see, the
Test at the line 8 is highlighted whereas the next
Test at the line 9 isn't.
In a word, I can set the highlight for the declaration class because I can use the regex to match the keyword
class. But the codes like the line 9 can't be matched by the regex. It seems that I should use some method to find the codes like the line 9 dynamically and highlight them.
I'm thinking if I can set an array to store all custom class name and highlight them but I don't know how to do it.