Skip to content

Instantly share code, notes, and snippets.

@jssteinberg
Last active June 1, 2023 11:38
Show Gist options
  • Save jssteinberg/56a53783dbb39ffc6a410fe548564aa9 to your computer and use it in GitHub Desktop.
Save jssteinberg/56a53783dbb39ffc6a410fe548564aa9 to your computer and use it in GitHub Desktop.
space_search -- search mapped to `s`, then enter with `space`
" 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
@jssteinberg
Copy link
Author

Further extended with buffer switcher here: https://gist.github.com/jssteinberg/49a41c52cbfa34918a7eaf8293595b42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment