aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--autoload/nohai.vim43
-rw-r--r--plugin/nohai.vim48
2 files changed, 45 insertions, 46 deletions
diff --git a/autoload/nohai.vim b/autoload/nohai.vim
new file mode 100644
index 0000000..726d4c8
--- /dev/null
+++ b/autoload/nohai.vim
@@ -0,0 +1,43 @@
+" Remaps <CR> in command mode to run `nohlsearch` after accepting the command.
+function! s:AddMapping()
+ silent! cnoremap <expr> <CR> <SID>CRAndNohlsearch()
+endfunction
+
+" Removes the Nohai <CR> cmap.
+function! s:RemoveMapping()
+ silent! cunmap <CR>
+endfunction
+
+" Deactivates the Nohai <CR> cmap and turns off the augroup.
+function! s:Deactivate()
+ call s:RemoveMapping()
+ call s:AutocmdOff()
+endfunction
+
+" Expr mapping function that runs the `nohlsearch` command after pressing <CR>.
+function! s:CRAndNohlsearch()
+ return "\<CR>:nohlsearch\<CR>"
+endfunction
+
+" Turn on Nohai autocmds.
+function! s:AutocmdOn()
+ augroup nohai
+ autocmd!
+
+ autocmd CmdlineEnter [/\?] call s:AddMapping()
+ autocmd CmdlineLeave [/\?] call s:Deactivate()
+ augroup END
+endfunction
+
+" Removes the Nohai augroup.
+function! s:AutocmdOff()
+ autocmd! nohai
+endfunction
+
+" Expr mapping function that turns on Nohai and starts the search command
+" specified by `command`, either '/' or '?'.
+function! nohai#Search(command)
+ call s:AutocmdOn()
+
+ return a:command
+endfunction
diff --git a/plugin/nohai.vim b/plugin/nohai.vim
index 3129ad0..f5c42aa 100644
--- a/plugin/nohai.vim
+++ b/plugin/nohai.vim
@@ -1,49 +1,5 @@
-" Remaps <CR> in command mode to run `nohlsearch` after accepting the command.
-function! s:AddMapping()
- silent! cnoremap <expr> <CR> <SID>CRAndNohlsearch()
-endfunction
-
-" Removes the Nohai <CR> cmap.
-function! s:RemoveMapping()
- silent! cunmap <CR>
-endfunction
-
-" Deactivates the Nohai <CR> cmap and turns off the augroup.
-function! s:Deactivate()
- call s:RemoveMapping()
- call s:AutocmdOff()
-endfunction
-
-" Expr mapping function that runs the `nohlsearch` command after pressing <CR>.
-function! s:CRAndNohlsearch()
- return "\<CR>:nohlsearch\<CR>"
-endfunction
-
-" Turn on Nohai autocmds.
-function! s:AutocmdOn()
- augroup nohai
- autocmd!
-
- autocmd CmdlineEnter [/\?] call s:AddMapping()
- autocmd CmdlineLeave [/\?] call s:Deactivate()
- augroup END
-endfunction
-
-" Removes the Nohai augroup.
-function! s:AutocmdOff()
- autocmd! nohai
-endfunction
-
-" Expr mapping function that turns on Nohai and starts the search command
-" specified by `command`, either '/' or '?'.
-function! s:Search(command)
- call s:AutocmdOn()
-
- return a:command
-endfunction
-
-nnoremap <expr> <Plug>(nohai-search-backward) <SID>Search('?')
-nnoremap <expr> <Plug>(nohai-search) <SID>Search('/')
+nnoremap <expr> <Plug>(nohai-search-backward) nohai#Search('?')
+nnoremap <expr> <Plug>(nohai-search) nohai#Search('/')
nmap g? <Plug>(nohai-search-backward)
nmap g/ <Plug>(nohai-search)