Remove VIM search highlight
You want the command :nohlsearch
, but you don't want to type that every time. Put this in your ~/.vimrc:
nnoremap <silent> <leader>n :nohlsearch<CR>
After that, you just enter your leader (which by default is \
) and then n
to clear the matches. You don't need to use n
; if you prefer, pick something else.
You can also remap your leader to something more comfortable, if you like. I use a comma:
let mapleader = ","
(That goes before the mapping to clear searches.)
i just /qiw772723euz
to "search" for something thats not in the file. hacky workaround, i know, i am interested in a real solution as well :)
Similar to @Telemachus answer above, a comment on this answer over at SO by @David Winslow suggested mapping a toggle of hlsearch
. You would map the following:
nmap <silent> <leader>n :set hlsearch!<CR>
Hitting n would then toggle highlight search off and on every time you hit it.