aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/nohai.vim
blob: e0afbb0e11ac7cac28fa69980a0c047e7bc74835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
augroup nohai
	autocmd!

	" autocmd CmdlineLeave * call s:Nohai(expand('<afile>'))
	autocmd CmdlineEnter [/?] call s:Nohai(expand('<afile>'))
augroup END

function! s:Nohai(cmdwin_char)
	if a:cmdwin_char == '/'
		" nohlsearch
		" ^ doesn't work because the autocommand executes before leaving the
		" command line window

		call s:AddMapping()
	else
		call s:RemoveMapping()
	endif
endfunction

function! s:AddMapping()
	silent! cnoremap <CR> <CR>:nohlsearch<CR>
endfunction

function! s:RemoveMapping()
	silent! cunmap <CR>
endfunction