Last active
June 1, 2023 11:38
-
-
Save jssteinberg/56a53783dbb39ffc6a410fe548564aa9 to your computer and use it in GitHub Desktop.
space_search -- search mapped to `s`, then enter with `space`
This file contains hidden or 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
" search with s in normal and visual mode | |
nnoremap s <cmd>let g:space_search=1<cr>/ | |
xnoremap s <cmd>let g:space_search=1<cr>/ | |
" backwards search with S in normal mode | |
nnoremap S <cmd>let g:space_search=1<cr>? | |
" in command mode, if space_search then <space> is <cr> | |
cnoremap <expr> <space> exists("g:space_search") | |
\ ? "<cr>" : " " | |
" autocmd to unlet variable so space_search is deactivated | |
augroup space_search | au! | |
au CmdlineLeave * if exists("g:space_search") | unlet g:space_search | en | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Further extended with buffer switcher here: https://gist.github.com/jssteinberg/49a41c52cbfa34918a7eaf8293595b42