To highlight any results found when searching in Vim, you can use
:set hlsearch. To turn off the highlighting, use
:nohlsearch. If search highlighting is something you always want turned on, you can add
set hlsearch (no colon) to your .vimrc file.
If, like me, you like to turn off the search highlighting after you’ve found what you’re looking for, you can map
:nohlsearch to one of the F keys. For example adding the following to your .vimrc:
noremap <silent> <F8> :nohlsearch<CR>
will highlight search results, and remove that highlighting when you press F8. Highlighting will be turned back on when you start your next search. When adding this to the .vimrc, be sure to hit the F8 key instead of typing in “<F8>”, or the shortcut won’t work.