diff options
Diffstat (limited to 'plugin/insert_suspend_hlsearch.vim')
-rw-r--r-- | plugin/insert_suspend_hlsearch.vim | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/plugin/insert_suspend_hlsearch.vim b/plugin/insert_suspend_hlsearch.vim index 635ed8e..2a88e8a 100644 --- a/plugin/insert_suspend_hlsearch.vim +++ b/plugin/insert_suspend_hlsearch.vim @@ -6,39 +6,17 @@ " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('loaded_insert_suspend_hlsearch') || &compatible - finish -endif -if !has('autocmd') || !has('extra_search') || v:version < 700 +if exists('loaded_insert_suspend_hlsearch') || &compatible && v:version < 700 finish endif let loaded_insert_suspend_hlsearch = 1 -" Initialise option saving variable -let s:hlsearch_save = &hlsearch - -" Save the current value of the 'hlsearch' option in a script variable, and -" disable it if enabled. Note that :nohlsearch does not work for this; see -" :help autocmd-searchpat. -function! s:Suspend() abort - let s:hlsearch_save = &hlsearch - if &hlsearch - set nohlsearch - endif -endfunction - -" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was -" called. -function! s:Restore() abort - if !&hlsearch && s:hlsearch_save - set hlsearch - endif -endfunction - " Clear search highlighting as soon as I enter insert mode, and restore it " once left augroup insert_suspend_hlsearch autocmd! - autocmd InsertEnter * call s:Suspend() - autocmd InsertLeave * call s:Restore() + autocmd InsertEnter * + \ call insert_suspend_hlsearch#Suspend() + autocmd InsertLeave * + \ call insert_suspend_hlsearch#Restore() augroup END |