Search code examples
searchvimhighlight

How do you make Vim unhighlight what you searched for?


I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.

Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.

Can't I just hit a magic key to kill the highlights when I'm done searching?


Solution

  • Just put this in your .vimrc

    " <Ctrl-l> redraws the screen and removes any search highlighting.
    nnoremap <silent> <C-l> :nohl<CR><C-l>