home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Disable (Or Toggle) Text Search Result Highlights In Vim and Neovim

January 2022

## Turning Highlights Off

Neovim/Vim highlights all the matching results when you do a text search in a file buffer. You can hide the highlights after the search with :noh but that's a pain to do every time. To disable them full time, add this to your ~/.config/nvim/init.vim or ~/.vimrc config file:

Code
set nohlsearch

## Toggling Highlights

Another option is to toggle the highlights on and off. Instead of using `set nohlsearch`, this can be done by adding the following to your config file:

Code
set hlsearch!
nnoremap <F5> :set hlsearch!<CR>

With that in place, hitting F5 will switch showing highlights on and off.

## One File Only

You can also run those commands directly in a single file buffer (prepended by a `:`) to apply to just that buffer. That is:

Code
:set nohlsearch

and

Code
set hlsearch!
nnoremap <F5> :set hlsearch!<CR>
═══ § ═══