diff options
-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 |