Last active
November 10, 2016 20:14
-
-
Save chrisbra/737b4b0487a7798af6f179bda9ce8c09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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