Use :hi to list all available {group} colors. Example call:
:match ErrorMsg /foobar/
^^ {group}
:call clearmatches()
:call matchadd('DiffAdd', '^ERROR.*')
^^ {group}
Again, use :hi to list all available colors. The exact colors will vary based on the color scheme you have loaded.
Sometimes I add this to my .vimrc:
" <leader>l = lock in the current-search pattern
" <leader>L = clear all locked-in search patterns
nnoremap <leader>l :call matchadd('Visual', @/)<cr>
nnoremap <leader>L :call clearmatches()<cr>
Some useful commands:
" display the list of current matches
:echo getmatches()
" use a hard-coded match ID, so we can overwrite just that specific match regex later
:silent! call matchdelete(100001) | call matchadd('IncSearch', 'my_custom_regex', 10, 100001)
" ^^^ This is my preferred solution right now. It works well!
" remember the match ID, so we can overwrite just that specific one later
:let w:match_database = matchadd('IncSearch', 'regex')
" (TODO: the above line isn't functional yet -- we need to add the 'matchdelete' somewhere)
" Use a hard-coded match ID, so we can overwrite just that specific match regex later.
let matchid_base = 100000
silent! call matchdelete(matchid_base + 1) | call matchadd('IncSearch', 'my_custom_regex', 10, matchid_base + 1)
silent! call matchdelete(matchid_base + 2) | call matchadd('ErrorMsg', 'my_custom_regex_2', 10, matchid_base + 2)