aboutsummaryrefslogtreecommitdiff
path: root/autoload
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 /autoload
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 'autoload')
-rw-r--r--autoload/insert_suspend_hlsearch.vim23
1 files changed, 23 insertions, 0 deletions
diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim
new file mode 100644
index 0000000..3000ac1
--- /dev/null
+++ b/autoload/insert_suspend_hlsearch.vim
@@ -0,0 +1,23 @@
+" Initialise option saving variable
+if !exists('g:insert_suspend_hlsearch#save')
+ let g:insert_suspend_hlsearch#save = 0
+endif
+
+" 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! insert_suspend_hlsearch#Suspend() abort
+ let g:insert_suspend_hlsearch#save = &hlsearch
+ if g:insert_suspend_hlsearch#save
+ set nohlsearch
+ endif
+endfunction
+
+" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was
+" called.
+function! insert_suspend_hlsearch#Restore() abort
+ if g:insert_suspend_hlsearch#save
+ set hlsearch
+ unlet g:insert_suspend_hlsearch#save
+ endif
+endfunction