Created
August 3, 2013 17:29
-
-
Save rbtnn/6147228 to your computer and use it in GitHub Desktop.
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
function! g:search() | |
let search_str = '' | |
let tmp = &l:hlsearch | |
try | |
setlocal hlsearch | |
while 1 | |
let n = getchar() | |
if n == char2nr("\<cr>") | |
break | |
elseif n == char2nr("\<esc>") | |
break | |
elseif n == char2nr("\<C-h>") || n == char2nr("\<bs>") || char2nr(n) == 0x80 | |
if 0 < len(search_str) | |
let search_str = search_str[:-2] | |
else | |
break | |
endif | |
else | |
let search_str .= nr2char(n) | |
endif | |
silent! execute '/' . search_str | |
redraw | |
echo '/' . search_str | |
endwhile | |
finally | |
let &l:hlsearch = tmp | |
endtry | |
endfunction | |
nnoremap <silent> / :<C-u>call g:search()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment