Last Updated: February 25, 2016
· glauco

Clear the last search highlighting in Vim

After you do a search in vim you get all the occurrences highlighted. When you don't want the highlight anymore, most people (me included) usually do another search for something gibberish that can't be found.

Today I just discovered that there is an easier way to do that. You just need to add the following line to your .vimrc and it's done!

nnoremap <esc> :noh<return><esc>

By putting that in your .vimrc you can then just press <esc> after you search to clear the highlighting from the previous search.

1 Response
Add your response

I just do /;slkdfj or whatever. no keymapping and instantaneous.

over 1 year ago ·