Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

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

## 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>