Carefully choose how you take input.
V can take input two different ways: input and args. It can even take both at the same time! Choosing how you take input can sometimes save you many bytes. Here is how the two input formats work:
The input is the text that is loaded into the buffer. Generally, this is more convenient for string inputs.
The args are stuffed into the first n registers, depending on how many args are given. For example, if 5 args are given, these will be loaded into registers a-e. Since you can run these registers with
@<reg>, these are generally more convenient for numeric input.
Lets make a hypothetical example. Our hypothetical challenge is:
Given a string s, and an integer n, output s n times, separated by a newline.
In vim, you can only take input into the buffer. So you'd need to take the input on two lines, for example
D to delete n into register '-', the
J to remove the extra newline, and then
@-p to paste s n times, and dd to take care of the extra copy. In V, you can take s as input, and n as an arg. Then you could shorten this too:
of course, there's still a few ways to shorten this even more. For example,
Ä makes n copies, rather than pasting n times. And
<M-@> will cycle through all of these args, so the first time it's called it is equivalent to
@a. So you can simply do:
À will command will also loop back once you go through all of the args. So if you have 3 arguments, running
À repeatedly will run