ID : 397
viewed : 274
Tags : vimfull-text-searchhighlightvim
To turn off highlighting until the next search:
Or turn off highlighting completely:
Or, to toggle it:
set hlsearch! nnoremap <F3> :set hlsearch!<CR>
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.
You can do
or :nohlsearch to temporarily disable search highlighting until the next search.
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.
" 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.