It's hard to say if a VimGolf challenge is "hard" or "easy". Every challenge is easy if you waste enough strokes. In Reverse Simple Deletion, just one stroke separates an easy 12 from an unreasonably difficult 11.
a.^H^M^[24@.ZZ for 11.
This is an optimized variation on the far more obvious
qqa^M^[q24@qZZ for 12.
The trick is the inserted text,
.^H^M. It's simultaneously the text to be inserted after the current letter, and the macro that will repeat the insert.
For the insert itself, you could just use
.^H is useless filler that cancels itself out by inserting a character and backspacing it.
For the macro, you could just use
^H^M is useless filler that cancels itself out by moving the cursor back a character (and up a line, since
^H runs from the beginning of the line), and down a line, to where it started.
^H is superfluous in both contexts, but it's essential to bind the two together. It cancels the
. in the insert, so you don't leave garbage in the file, and it cancels the
^M in the macro, so it doesn't run from the last line and fail the macro.
Note that you can't use
25a^M^[, because that just puts 25 line breaks between
b. Similarly, you can't use
a^M^[24., because that puts 24 line breaks between
. with a number argument doesn't mean to repeat
. that many times; it means run the last command with a changed numeric argument.
.. are not the same thing. You could use
. repeats to finish this challenge, but it would look like
........................; that's why you need a macro.
Read the manual
:help 'whichwrap': The
'nocompatible'default of this setting lets you use Backspace and Space to ignore line breaks while moving the cursor left or right. This is the reason
^Hmoved the cursor up a line.
- Generate English Alphabets: If you could just find an alphabet somewhere, the rest of the challenge would be the same...
- Increment, increment, increment....: With Reverse Simple Deletion broken, this is the undisputed champion of basic macro demonstrations.
- VimGolfNight: Another basic macro demonstration.
- The name of the game: This challenge tried to be a simple macro demonstration, but it kinda blew it.
- Reverse characters in a line: Another tricky macro of similar size.