Last active
May 26, 2017 13:57
-
-
Save sunjon/ca9175d43e8435973322e4cafbbb792b to your computer and use it in GitHub Desktop.
Tab through partial HLS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Tab to cycle through instances of partially complete search pattern {{{ | |
set wildcharm=<Tab> | |
cnoremap <expr> <Tab> BetterIncSearch('tab') | |
cnoremap <expr> <S-Tab> BetterIncSearch('stab') | |
" better incremental search | |
function! BetterIncSearch(key) abort | |
if getcmdtype() ==# '/' || getcmdtype() ==# '?' | |
if (a:key ==# 'tab' && v:searchforward) || (a:key ==# 'stab' && !v:searchforward) | |
return "\<CR>/\<C-r>/" | |
else | |
return "\<CR>?\<C-r>/" | |
endif | |
else | |
if a:key ==# 'tab' | |
return "\<Tab>" | |
else | |
return "\<S-Tab>" | |
endif | |
endif | |
endfunction | |
" }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment