There are four options (two of which were suggested by others):
Use the after structure in vimfiles (~ / .vim / after / syntax / cpp.vim):
:help after-directory
Use a match for the current window:
:match really_unique_name "[()]"
Use matchadd () again for the current window, but this allows you to remove individual matches if you need to:
:call matchadd('really_unique_name', "[()]") " Or :let MyMatchID = matchadd('really_unique_name', "[()]") " and then if you want to switch it off :call matchdelete(MyMatchID)
Install the Dr Chip rainbow.vim plugin to get the highlight in different colors depending on the indentation level.
In this situation, I would recommend option 1, since it looks like you want to make it part of the general syntax. If you want to use matches and want them to be buffer-specific (and not specific to a window), you will need something like:
function! CreateBracketMatcher() call clearmatches() call matchadd('really_unique_name', "[()]") endfunc au BufEnter <buffer> call CreateBracketMatcher()
For more information see
:help after-directory :help :match :help matchadd() :help matchdelete() :help clearmatches() :help function! :help autocmd :help autocmd-buffer-local :help BufEnter
You may also be interested in my answer to this question , which covers a more general operator highlight.
source share