aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-17 15:47:58 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-17 15:47:58 +1200
commit6e626e4f4b969480495a72ce94599be8c85351f6 (patch)
treee5d066fce1e599c56651e4c10db1098eb4999a98 /plugin
parentAdd VERSION (diff)
downloadvim-insert-suspend-hlsearch-6e626e4f4b969480495a72ce94599be8c85351f6.tar.gz
vim-insert-suspend-hlsearch-6e626e4f4b969480495a72ce94599be8c85351f6.zip
Use autoload since we have Vim >= 7.0
Diffstat (limited to 'plugin')
-rw-r--r--plugin/insert_suspend_hlsearch.vim27
1 files changed, 2 insertions, 25 deletions
diff --git a/plugin/insert_suspend_hlsearch.vim b/plugin/insert_suspend_hlsearch.vim
index afd8800..5dd1e74 100644
--- a/plugin/insert_suspend_hlsearch.vim
+++ b/plugin/insert_suspend_hlsearch.vim
@@ -14,33 +14,10 @@ if !has('autocmd') || !has('extra_search') || v:version < 700
endif
let g:loaded_insert_suspend_hlsearch = 1
-" 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:HlsearchSuspend()
- let s:hlsearch_save = &hlsearch
- if s:hlsearch_save
- set nohlsearch
- endif
-endfunction
-
-" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was
-" called.
-function! s:HlsearchRestore()
- if s:hlsearch_save
- set hlsearch
- endif
- unlet s:hlsearch_save
-endfunction
-
" Clear search highlighting as soon as I enter insert mode, and restore it
" once left
augroup insert_suspend_hlsearch
autocmd!
- autocmd InsertEnter
- \ *
- \ call <SID>HlsearchSuspend()
- autocmd InsertLeave
- \ *
- \ call <SID>HlsearchRestore()
+ autocmd InsertEnter * call insert_suspend_hlsearch#Suspend()
+ autocmd InsertLeave * call insert_suspend_hlsearch#Restore()
augroup END