I often repeat the following commands when I edit code:

  • yy - yank the line
  • gcc - comment out the line (so that I can visually see all the changes later)
  • p - paste back the copied version what I will edit
  • i - jump into insert mode

I tried to do the mapping as

nnoremap yc yygccpi

The problem seems to be with the commentary plugin's key-combination. Even if I remap gcc to yc, nothing happens. Other bindings, like yyp and 3l, are working. The nnoremap is at the end of my vimrc, well after the packloadall command.

How could I accomplish this keymapping, and what was the problem?

  • 1
    I would say you should put :normal yygccpi in the last column instead of just yygccpi to have it type it exactly as in normal mode.. I can't remember the exact reason we use :normal instead, but :normal is exactly as typing it key by key in ---[NORMAL]--- mode. Normally you'd use :normal! (plus asterisk) to ignore mappings, but I'm pretty sure gcc is a mapping so thats not what you want in this case :) read also :help :normal
    – dza
    Jan 17, 2020 at 11:56
  • 2
    Or just use nmap, no need to :normal
    – Maxim Kim
    Jan 17, 2020 at 12:00

1 Answer 1


Change you mapping to nmap instead of nnoremap.

nnoremap uses "default" mappings on the right mapped side (it doesn't allow nested mappings, like gcc).


nmap yc yygccpi

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.