vim-surround icon indicating copy to clipboard operation
vim-surround copied to clipboard

Customize default key mapping

Open Anfid opened this issue 7 years ago • 3 comments

Hello. Is there an option in this plugin to change the default mappings to a different ones? I use 's' key as back motion (vanilla 'b') and would really like not to sacrifice combinations like ds, ys etc. in favor of this plugin.

Anfid avatar Nov 09 '18 18:11 Anfid

Take a look at https://github.com/tpope/vim-surround/blob/master/plugin/surround.vim#L590 to see how the maps are defined. You can define your own in your .vimrc or some other script and disable the default maps by let g:surround_no_mappings=1

graywh avatar Dec 17 '18 21:12 graywh

Thank you for your help. Then I think it is a documentation issue. I think it should be mentioned in the docs or readme

Anfid avatar Dec 19 '18 12:12 Anfid

What if I want to change this line: https://github.com/tpope/vim-surround/blob/master/plugin/surround.vim#L140

Default: let pairs = "b()B{}r[]a<>"

For tihs: let pairs = "b()c{}s[]a<>"

So the s works for deleting (dss), for changing (cssb), for inserting (Ss), and so on.

I tried to remap with this: let b:surround_{char2nr('s')} = "[\r]", however I still have to use the r.

Is it possible to change deeply the default keymapping? Thanks.

gerardbm avatar Nov 14 '21 14:11 gerardbm