aboutsummaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorTeddy Wing2019-12-05 02:16:30 +0100
committerTeddy Wing2019-12-05 02:16:30 +0100
commit03ac5871f7ea599a8ca945e277d1a2243f572e90 (patch)
tree19f1ae6d34eccb6895d924cfe2579c72142a823b /plugin
parent47588e81201656b2892048aa8795cb5efd04fa6b (diff)
downloadvim-nohai-03ac5871f7ea599a8ca945e277d1a2243f572e90.tar.bz2
New idea for 'nohlslash' search commands
Sort of working. Seems like the right approach.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/nohai.vim26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugin/nohai.vim b/plugin/nohai.vim
new file mode 100644
index 0000000..e0afbb0
--- /dev/null
+++ b/plugin/nohai.vim
@@ -0,0 +1,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