What I want to do is make CursorMoved
autocmd that would check if there is a search highlight is on and if it is it would start a timer that would deactivate it.
PS I know about all available workarounds like this plugin etc. They aren't good enough.
search()
with the content of@/
: if the result is not zero, then the last search has a match in the buffer and you can then use:nohl
. See:h search()
,:h @/
(and:h setreg()
to handle registers properly):nohl
in timer (I hope I can, because:noh
by itself doesn't work in autocmd. Doing:noh
should be less expensive than search I guess.hlsearch
and:nohlsearch
is precisely that they can't be used in functions or autocommands. This is what forces everyone to look for hacky workarounds. Also, keep in mind that timers didn't exist until very recently.