aboutsummaryrefslogtreecommitdiff
path: root/autoload/insert_suspend_hlsearch.vim
blob: 4408d52bf2856475cc0020ee51f204ea8d8ca06a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
" Suspend 'hlsearch' if set, add hook to restore on insert completion
function! insert_suspend_hlsearch#() abort

  " 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 *
        \ set hlsearch
        \|autocmd! insert_suspend_hlsearch InsertLeave

endfunction