aboutsummaryrefslogtreecommitdiff
path: root/plugin/insert_suspend_hlsearch.vim
blob: 5dd1e74942833eb832f703c4b0a99720b9dc355d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"
" insert_suspend_hlsearch.vim: If 'hlsearch' is enabled, switch it off when
" the user starts an insert mode operation, and back on again when they're
" done.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
if exists('g:loaded_insert_suspend_hlsearch') || &compatible
  finish
endif
if !has('autocmd') || !has('extra_search') || v:version < 700
  finish
endif
let g:loaded_insert_suspend_hlsearch = 1

" Clear search highlighting as soon as I enter insert mode, and restore it
" once left
augroup insert_suspend_hlsearch
  autocmd!
  autocmd InsertEnter * call insert_suspend_hlsearch#Suspend()
  autocmd InsertLeave * call insert_suspend_hlsearch#Restore()
augroup END