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
/klsdf<CR>
-
do
:nohl
command or -
map a key to do it —
:nnoremap <C-l> :nohl<CR><C-l>
-
etc
My take to this problem is … not to use hlsearch
:
" 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 /
or ?
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:
@joeytwiddle your plugin looks a lot like the first iteration of mine before I figured out that mapping
n
,N
and friends caused more troubles than it solved.