-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
neovim/neovim
#29393Labels
Description
'hlsearch' is very useful but at the same time too intrusive.
Help topic states specifically that :nohlsearch doesn't work in autocommand (actually it also doesn't work in timer callbacks) so there is no obvious way to make it auto turned off.
There is vim-cool plugin by @romainl and the essense of it might be the following snippet I am currently using:
# turn off hlsearch after:
# - doing nothing for 'updatetime'
# - getting into insert mode
augroup auto_nohlsearch | au!
set updatetime=2000
noremap <Plug>(nohlsearch) <cmd>nohlsearch<cr>
noremap! <expr> <Plug>(nohlsearch) execute('nohlsearch')[-1]
au CursorHold * call feedkeys("\<Plug>(nohlsearch)", 'm')
au InsertEnter * call feedkeys("\<Plug>(nohlsearch)", 'm')
augroup END
Should we add this example, even though it is "hackish", to the help topic right after :h :nohlsearch or maybe even a simple plugin in the same way comment was added?
nickspoons