machakann/vim-sandwich

How do I only disable `S` in visual mode?

kohane27 opened this issue ยท 2 comments

Hello! Great plugin! Replaced surround.vim and am loving it! Still blown away by dss and css: it's cognitively easier and feels intuitive.

Current setting in my sandwitch.lua:

vim.cmd([[
    runtime macros/sandwich/keymap/surround.vim
    " Text objects to select 
    " the nearest surrounded text automatically
    xmap iss <Plug>(textobj-sandwich-auto-i)
    xmap ass <Plug>(textobj-sandwich-auto-a)
    omap iss <Plug>(textobj-sandwich-auto-i)
    omap ass <Plug>(textobj-sandwich-auto-a)
]])

So I'm using the vim-surround compatible keymappings. However, I'm also using lightspeed.nvim in which it also takes over s and S. I'd like to disable vim-sandwich's S in visual mode. Or preferably, I'd like to remap S to gs for visual mode in vim-sandwich.

I've read the help doc and it seems there's no way to disable individual mappings. I could disable all default mappings with let g:sandwich_no_default_key_mappings = 1 and remap each one back (except visual mode S), but I'm not sure if it's also compatible with surround.vim.

Any help is much appreciated. Thank you again for such a great plugin!

Hi, probably an easy solution is to copy and rename the script (macros/sandwich/keymap/surround.vim). Then, comment out the corresponding line and :source it.

Another solution is to re-map the lightspeed key mapping to overwrite, probably this?.

xmap S <Plug>Lightspeed_S

Note that the following line should come after the line runtime macros/sandwich/keymap/surround.vim.

@machakann

Thank you for looking into the issue. Re-mapping lightspeed again works:

vim.cmd([[
    runtime macros/sandwich/keymap/surround.vim
    " remap lightspeed to override again
    xmap S <Plug>Lightspeed_S
]])

I only thought of resolving the keymapping conflict but didn't think of remapping lightspeed again. Thank you for going one step further and look into the lightspeed doc for me. I really appreciate it.