Skip to content

Instantly share code, notes, and snippets.

@jssteinberg
Created June 1, 2023 11:32
Show Gist options
  • Save jssteinberg/49a41c52cbfa34918a7eaf8293595b42 to your computer and use it in GitHub Desktop.
Save jssteinberg/49a41c52cbfa34918a7eaf8293595b42 to your computer and use it in GitHub Desktop.
SPACE CONFIRMS - maps to cmdline that are confirmed with <space>
" SPACE CONFIRMS - maps to cmdline that are confirmed with <space>
" Setup:
" <space> is enter key in command mode if space_confirms
cno <expr> <space> exists("g:space_confirms") ? "<cr>" : " "
" space_confirms is unlet by autocmd so it's deactivated
augroup space_confirms | au!
au CmdlineLeave * if exists("g:space_confirms") | unlet g:space_confirms | en
augroup end
" Mappings:
" search in normal and visual mode
nn s <cmd>let g:space_confirms=1<cr>/
xn s <cmd>let g:space_confirms=1<cr>/
" backward search in normal mode
nn S <cmd>let g:space_confirms=1<cr>?
" switch buffer in normal mode
nn <leader><tab> <cmd>let g:space_confirms=1<cr>:buffer <c-z>
@jssteinberg
Copy link
Author

jssteinberg commented Jun 1, 2023

An extension of https://gist.github.com/jssteinberg/56a53783dbb39ffc6a410fe548564aa9

Use to confirm Vim commands from mappings. Can replace plugins like search motions plugins (leap.nvim, lightspeed.nvim, vim-sneak, etc) and buffer switcher plugins.

Use with options:

set wildignorecase wildmode=lastused:full wildignore+=**/node_modules/**,**/.git/**
" Vim (not Neovim) need:
set nocompatible " obviously
set wildcharm=<c-z> " Enable usage in map target

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