Simply type
:noh<cr>
(Where <cr>
symbolizes a carriage return, i.e. Enter.) The full non-abbreviated version of this command is :nohlsearch
.
For convenience, you can have a mapping such as
nnoremap <Leader><space> :noh<cr>
in your .vimrc
. Since my leader is Space, this allows me to clear highlighting simply by tapping space twice. (By default, <Leader>
is set to \
)
Another popular option is to bind it to Ctrl+L, since this is more or less the default for 'redrawn terminal screen', which is very roughly what you're doing:
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
This has the side-effect of also redrawing the terminal screen, which might be slow if your terminal connection is slow (which is very rare these days).
NOTE: If you're using tpope/vim-sensible then it already offers the <C-l>
mapping listed above.
/skldafjlksjdf
;):nnoremap <silent> <CR> :nohlsearch<CR><CR>
. Hit return in command mode, and the highlighting disappears.