Skip to content

Instantly share code, notes, and snippets.

@chrisbra
Last active November 10, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbra/737b4b0487a7798af6f179bda9ce8c09 to your computer and use it in GitHub Desktop.
Save chrisbra/737b4b0487a7798af6f179bda9ce8c09 to your computer and use it in GitHub Desktop.
func! SearchHighlight(timer) abort
if !v:hlsearch || mode() isnot 'n'
return
else
let cmd="\<c-\>\<c-n>:let v:hlsearch=0\<cr>\<c-l>"
sil call feedkeys(cmd, 'n')
endif
endfu
func! s:TimerHighlight() abort
if exists("g:search_timer_id")
return
else
let g:search_timer_id = timer_start(7000, 'SearchHighlight', {'repeat': -1}) endif
endfunction
func! s:SearchHighlightInit() abort
if exists("g:search_timer_id")
sil! call timer_stop(g:search_timer_id)
unlet! g:search_timer_id
endif
augroup SearchHighlight
au!
au CursorMoved * call s:TimerHighlight()
augroup end
endfu
:com! SearchHighlightTimer :call s:SearchHighlightInit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment