Tip 67Play Back with a Count

The Dot Formula can be an efficient editing strategy for a small number of repeats, but it can’t be executed with a count. Overcome this limitation by recording a cheap one-off macro and playing it back with a count.

In Tip 3, we used the Dot Formula to transform this:

 var​ foo = ​"method("​+argument1+​","​+argument2+​")"​;

What we want is for it to look like this:

 var​ foo = ​"method("​ + argument1 + ​","​ + argument2 + ​")"​;

The Dot Formula meant that we could complete the task simply by repeating ;. a few times. What if we faced the same problem but on a larger scale?

 x = ​"("​+a+​","​+b+​","​+c+​","​+d+​","​+e+​")"​;

We can approach this in exactly the same way. But when ...

Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.