Vim clear last search highlighting

ID : 397

viewed : 140

Tags : vimfull-text-searchhighlightvim

Top 5 Answer for Vim clear last search highlighting

vote vote

90

To turn off highlighting until the next search:

:noh 

Or turn off highlighting completely:

set nohlsearch 

Or, to toggle it:

set hlsearch!  nnoremap <F3> :set hlsearch!<CR> 
vote vote

83

From the VIM Documentation

To clear the last used search pattern:

:let @/ = "" 

This will not set the pattern to an empty string, because that would match everywhere. The pattern is really cleared, like when starting Vim.

vote vote

77

You can do

:noh 

or :nohlsearch to temporarily disable search highlighting until the next search.

vote vote

61

I found this answer years ago on vim.org:

Add the following to your .vimrc:

"This unsets the "last search pattern" register by hitting return nnoremap <CR> :noh<CR><CR> 

Thus, after your search, just hit return again in command mode, and the highlighting disappears.

vote vote

51

From http://twitter.com/jonbho/status/2194406821

" Clear highlighting on escape in normal mode nnoremap <esc> :noh<return><esc> nnoremap <esc>^[ <esc>^[ 

The second line is needed for mapping to the escape key since Vim internally uses escape to represent special keys.

Top 3 video Explaining Vim clear last search highlighting

Related QUESTION?