I'm using the nerdcommenter to comment and uncomment my c++ code.

Basically I use \cc to comment one line, \cu to uncomment, \ca to switch the delimiters (switch // to /**/ or switch back).

Now I want to set a shortcut named \cv for this case:

\cv: \ca + \cc + \ca

so that I can use the other delimiter quickly.

I've tried to add nnoremap <leader>cv <leader>ca \| <leader>cc \| <leader>\ca into my ~/.vimrc but it doesn't work.

1 Answer 1



nmap <leader>cv <leader>ca<leader>cc<leader>ca

Note that you can't use nore-stuff here.

  • Great it works. May I know why?
    – Yves
    Sep 3, 2019 at 12:20
  • 1
    @Yves Because this mapping does depend on the other mapping(s). While all noremap commands effectively ignore all other mappings and allow to use only "standard" commands on the right-hand side. Usually this is preferred, as this prevents the conflicts between mappings, but not in this case. BTW. If the plugin also exports some functions or <plug>s with the desired functionality, then, as a matter of style, it's better to map to them rather than to "the hotkeys". This way it would be harder (or even imposssible) to break the things up with some other nmap.
    – Matt
    Sep 3, 2019 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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