Created
March 1, 2019 18:07
-
-
Save PeterRincker/1ef979aee5bc0b34c074247e30897105 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
" Cancel searching with `/`, but stay in place | |
cnoremap <expr> <c-y> <SID>search_cr("\<c-y>", getcmdtype(), getcmdline()) | |
function! s:search_cr(cmd, type, line) | |
let [key, s:pos, s:search] = [a:cmd, getpos('.'), a:line] | |
if a:type == '/' || a:type == '?' | |
let key = "\<c-c>" | |
augroup search_cr | |
autocmd! | |
autocmd CmdlineLeave * execute "autocmd! search_cr" | | |
\ call setpos('.', s:pos) | | |
\ call search(s:search, 'bcW') | |
augroup END | |
endif | |
return key | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment