How do I disable vim-surround in visual (selection) mode?
IE. If I hit shift+S I want to replace all the lines I have currently selected ( the normal vim functionality )
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityHow do I disable vim-surround in visual (selection) mode?
IE. If I hit shift+S I want to replace all the lines I have currently selected ( the normal vim functionality )
You can simply unmap it just as any other mapping in Vim. But if doing this from vimrc you have to delay the unmap until the plugin was actually loaded. If using Vim8 builtin :h packages
that happens after your vimrc has been processed. Therefore some additional steps must be taken. The rest is how to deal with this particular problem.
There are several ways to do so.
0) Actually, you can tell the plugin to disable all builtin mappings and create ones you really use manually:
let g:surround_no_mappings = 1
" copied from plugin/surround.vim
nmap ds <Plug>Dsurround
nmap cs <Plug>Csurround
nmap cS <Plug>CSurround
nmap ys <Plug>Ysurround
nmap yS <Plug>YSurround
nmap yss <Plug>Yssurround
nmap ySs <Plug>YSsurround
nmap ySS <Plug>YSsurround
" ----- remove these -----
"xmap S <Plug>VSurround
"xmap gS <Plug>VgSurround
imap <C-S> <Plug>Isurround
imap <C-G>s <Plug>Isurround
imap <C-G>S <Plug>ISurround
1) Unmap on VimEnter:
augroup vimrc_unmap | au!
autocmd VimEnter * ++once xunmap S
autocmd VimEnter * ++once xunmap gS
augroup end
2) Force early plugin load and then unmap it:
packadd vim-surround
xunmap S
xunmap gS
3) "Polish" your setup from after/plugin/
subdirectory
~/.vim/after/plugin/final.vim
" delete superfluous vim-surround mappings
xunmap S
xunmap gS
xunmap S
did the trick. Thanks! packadd didn't seem to ever work.. I use Plug 'machakann/vim-sandwich'
to load it.
xunmap S
right in vimrc. plug loads it early enough. Cool.
:h packages
(or a minimalistic plugin manager built on top of it, such as minpac, vim-packager etc.). Otherwise you should consult your plugin manager documentation to find out if it delays plugin load or not, and how to change this.
:h v_S
is the same as:h v_s
if current visual mode islinewise
.