paperlined.org
apps > vim
document updated 12 days ago, on Feb 10, 2025

custom highlights in Vim

custom syntax rules

Using search highlighting can allow you to MUCH more quickly scan and grok code. It's so useful that it's worth knowing about all the tiny variants-on-the-theme:

getting more precise control over highlights

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)

related configuration settings

plugins

Plugins that work with hilighting: