I often repeat the following commands when I edit code:
yy
- yank the linegcc
- comment out the line (so that I can visually see all the changes later)p
- paste back the copied version what I will editi
- 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?
:normal yygccpi
in the last column instead of justyygccpi
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
nmap
, no need to:normal