After searching in Vim with / all occurences highlighted and this stays for a while. It may be a unwanted or even annoying thing. There are many methods to disable it;
0: Temporarily Disable
To turn off highlight until next search, in exe mode:
:noh
1: Persistent Disable
If you want to disable it completely:
1.0: For existing session/buffer:
In exe mode:
:set nohlsearch
1.1: For all sessions/buffers:
Put this in your .vimrc:
" disable search highlight
set nohlsearch
P.S:
I personally use 'temporarily disable' with key mapping. I mapped :noh to <esc> key. Since hitting <esc> is a very common and intuitive situtation in Vim.
" noh - no highlight
map <esc> :noh <CR>
You can also map nohlsearch to a key for toggling.
All done!
Top comments (0)