Vim Highlighting
I highlight my searches in VIM using the following in my .vimrc:
" Highlight search terms... set hlsearch set incsearch " ...dynamically as they are typed. nmap n :silent :nohlsearch " stop highlighting with n
While demoing or in a code review it is nice to highlight more than one item. You can use searching to match multiple words:
/term1\|term2
Note: You can also us CTRL+R followed by a ‘/’ to paste the exact last search term
However, it is also nice to do highlights in different colors – or to keep a highlight persistent while you search for other terms. To do this I use:
:match Search /pattern/
Now this will use the same highlight color as normal search. You can replace Search, the name of the highlight group, with another group to highlight with a different color (tab completion works here).
To disable the highlighting from match use:
:match none
Enjoy highlighting!
Categories