3

I don't mind keeping the original mapping, I just want to bind it to something more convenient, so instead of typing ysiw), I could for example do it with Alt(.

I tried just adding nnoremap <M-(> ysiw) to my .vimrc, but that did nothing.

I use gVim 8, thanks in advance

3

First of all, you need to use nmap, not nnoremap, since s is already a mapping from Surround plugin. nmap scans right side for further mappings - see :h :nmap.

As of notation <M-(> - I'm not sure if it's correct. I would do it as follows (and I actually tested it like so) - while editing your .vimrc in gVim in place of <M-(> press Ctrlv and then your combination AltShift9 - this will insert actual key code. It should look like so:

nmap ¹ ysiw)
3

As mentioned by grodzik, nnoremap does not take any non-standard mappings into account. That includes mappings by plugins. Simply changing to nmap is not the right way to go in my opinion. You will start to get used to Alt ( and not need ysiw) anymore. With an nmap you will never be able to map something else to ysiw) (or ys) because that will break the Alt ( mapping.

I think you should map directly to the vim-surround commands. In this case that would be

nnoremap <M-(> :execute "normal \<Plug>Ysurroundiw)"<cr>

This calls <Plug>Ysurround which is usually done using ys and then does the iw) part. Other commands can be found in the surround.vim file that is part of the vim-surround plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.