Get rid of Vim's highlight after searching text
In VIM, after finding text with "/" command, that text remains highlighted.
What is the command to remove that? I don't want to remove highlighting capability at all, but don't want to have all those bright text spots once I've found what I need.
Thanks.
Solution 1:
Type this:
:noh
Solution 2:
You can toggle it with
:set hls!
Of course a quick and dirty alternative is to do another search for gibberish:
/asdsad
I usually bind a key to :set hls!
to make this easy and use the gibberish approach when I'm in vim on some machine I don't have my profile installed on.
Solution 3:
Completely disable search highlights
:set nohlsearch
Clear until next search
:nohlsearch
or :noh
for short. This clears highlights until a new search is performed or n or N is pressed
Clear on pressing custom map
-
Clear highlights on hitting the ESC key
nnoremap <esc> :noh<return><esc>
-
Clear highlights on pressing \ (backslash) twice
nnoremap \\ :noh<return>
Solution 4:
I'm lazy and type something like /asdf
then slap the RETURN
key.
Solution 5:
I have this in my .vimrc:
map <leader>h :set hlsearch!<cr>
So when I type:
\h
It toggles highlighting on/off.