Annoying vim search highlight "everyone" tries to get rid of
You have turned on
hlsearch for some reason in your vim config (well
obviously to highlight your searches) but it gets in your way, right?
Now you try to find a solution to this problem, like
spam random searches
map a key to do it —
:nnoremap <C-l> :nohl<CR><C-l>
My take to this problem is … not to use
" highlight incremental searches set incsearch " to use with <tab> cnoremaps set wildcharm=<C-z> " tab to cycle search candidates cnoremap <expr> <Tab> getcmdtype() =~ "[/?]" ? "<C-g>" : "<C-z>" cnoremap <expr> <S-Tab> getcmdtype() =~ "[/?]" ? "<C-t>" : "<S-Tab>"
Or use it only when in
? because it is still useful to highlight occurences while typing so you might also add following:
"" highlight all occurrences of a term being searched/replaced augroup hlsearch | au! au CmdlineEnter /,\? :set hlsearch au CmdlineLeave /,\? :set nohlsearch augroup end
And it looks like this: