aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2019-12-05 02:16:30 +0100
committerTeddy Wing2019-12-05 02:16:30 +0100
commit03ac5871f7ea599a8ca945e277d1a2243f572e90 (patch)
tree19f1ae6d34eccb6895d924cfe2579c72142a823b
parent47588e81201656b2892048aa8795cb5efd04fa6b (diff)
downloadvim-nohai-03ac5871f7ea599a8ca945e277d1a2243f572e90.tar.bz2
New idea for 'nohlslash' search commands
Sort of working. Seems like the right approach.
-rw-r--r--nohlslash.vim17
-rw-r--r--plugin/nohai.vim26
2 files changed, 26 insertions, 17 deletions
diff --git a/nohlslash.vim b/nohlslash.vim
deleted file mode 100644
index 9088cd1..0000000
--- a/nohlslash.vim
+++ /dev/null
@@ -1,17 +0,0 @@
-let s:nohlslash = 0
-
-function! s:setup_nohlslash()
- let s:nohlslash = !s:nohlslash
-endfunction
-
-nnoremap <silent> <leader>a :call <SID>setup_nohlslash()<cr>
-
-
-augroup nohlslash
- autocmd!
- autocmd CmdwinLeave *
- \ if s:nohlslash |
- \ echom 'test'
- \ nohlsearch
- \ endif
-augroup END
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