" Initialise option saving variable let s:hlsearch = &hlsearch " 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 s:hlsearch = &hlsearch if s:hlsearch set nohlsearch endif endfunction " Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was " called. function! insert_suspend_hlsearch#Restore() abort if s:hlsearch set hlsearch endif endfunction