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 | |
parent | Merge branch 'release/v2.0.0' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-insert-suspend-hlsearch-cbdb61b624caa1670e091f901c2bdd7e76e05414.tar.gz vim-insert-suspend-hlsearch-cbdb61b624caa1670e091f901c2bdd7e76e05414.zip |
* release/v2.1.0:
Further refactor/simplify
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/insert_suspend_hlsearch.vim | 13 |
2 files changed, 11 insertions, 4 deletions
@@ -1 +1 @@ -2.0.0 +2.1.0 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 |