diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-05 22:52:10 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-05 22:52:10 +1200 |
commit | cbdb61b624caa1670e091f901c2bdd7e76e05414 (patch) | |
tree | c4eb163b3ce0cfa5963cba0d7b4031249e9fc02f /autoload | |
parent | Merge branch 'release/v2.0.0' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-insert-suspend-hlsearch-master.tar.gz vim-insert-suspend-hlsearch-master.zip |
* release/v2.1.0:
Further refactor/simplify
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/insert_suspend_hlsearch.vim | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim index de43d10..4408d52 100644 --- a/autoload/insert_suspend_hlsearch.vim +++ b/autoload/insert_suspend_hlsearch.vim @@ -1,8 +1,15 @@ -" Save value of 'hlsearch' into a variable, and disable it +" Suspend 'hlsearch' if set, add hook to restore on insert completion function! insert_suspend_hlsearch#() abort - let s:hlsearch = &hlsearch + + " Nothing to do if 'hlsearch' isn't set + if !&hlsearch + return + endif + + " Turn off 'hlsearch' and set a hook to re-enable it when insert mode ends set nohlsearch autocmd insert_suspend_hlsearch InsertLeave * - \ let &hlsearch = s:hlsearch + \ set hlsearch \|autocmd! insert_suspend_hlsearch InsertLeave + endfunction |