I'm making a shortcut that places a # at the front of each line, in the next x lines. x is a number I type before entering the shortcut, like typing 11dd
deletes the next eleven lines.
The command is .,+10 s/^/#/g
. Here the number ten should really be whatever was typed before the shortcut. How do I make the shortcut change according to the number that was typed before it?
Added after question was answered:
So now I have the following in the .vimrc:
nmap c1 :s/^/#/g<esc>``
nmap c0 :s/^#//g<esc>``
Which allows me to type 13ac
, to add #
at the front of the next 13 lines, and 13dc
to delete any #
at the front of the next 13 lines.
It's better than =pod
and =cut
for they cause errors when nested.
c1=comment add,
c0=comment delete.
# is used in Perl.