Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to disable auto nohl #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/is.txt
Expand Up @@ -100,5 +100,9 @@ g:is#do_default_mappings *g:is#do_default_mappings*
Default: 1
Set this option to 0 if you want to disable the default mappings.

g:is#auto_nohlsearch *g:is#auto_nohlsearch*
Default: 1
Set this option to 0 if you want to disable the auto nohlsearch

==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:fdm=marker:
26 changes: 14 additions & 12 deletions plugin/is.vim
Expand Up @@ -43,7 +43,7 @@ map <Plug>(is-#) <Plug>(is-nohl)<Plug>(_is-#)
map <Plug>(is-g*) <Plug>(is-nohl)<Plug>(_is-g*)
map <Plug>(is-g#) <Plug>(is-nohl)<Plug>(_is-g#)

if exists('##CmdlineLeave')
if exists('##CmdlineLeave') && get(g:, 'is#auto_nohlsearch', 1)
augroup plugin-is
autocmd!
autocmd CmdlineLeave [/\?] :call is#auto_nohlsearch(2)
Expand All @@ -57,17 +57,19 @@ if get(g:, 'is#do_default_mappings', 1)
if mapcheck("\<C-k>", 'c') ==# ''
cmap <C-k> <Plug>(is-scroll-b)
endif
for s:map in ['n', 'N', '*', '#', 'g*', 'g#']
if mapcheck(s:map, 'n') ==# ''
execute printf(':nmap %s <Plug>(is-%s)', s:map, s:map)
endif
if mapcheck(s:map, 'x') ==# ''
execute printf(':xmap %s <Plug>(is-%s)', s:map, s:map)
endif
if mapcheck(s:map, 'o') ==# ''
execute printf(':omap %s <Plug>(is-%s)', s:map, s:map)
endif
endfor
if get(g:, 'is#auto_nohlsearch', 1)
for s:map in ['n', 'N', '*', '#', 'g*', 'g#']
if mapcheck(s:map, 'n') ==# ''
execute printf(':nmap %s <Plug>(is-%s)', s:map, s:map)
endif
if mapcheck(s:map, 'x') ==# ''
execute printf(':xmap %s <Plug>(is-%s)', s:map, s:map)
endif
if mapcheck(s:map, 'o') ==# ''
execute printf(':omap %s <Plug>(is-%s)', s:map, s:map)
endif
endfor
endif
unlet s:map
endif

Expand Down