Apparently I was a bit sloppy with my wording because everyone missed the fact that there was a second part to this challenge. Every line that started with an “open figure” was supposed to be deleted. That was just a matter of deleting every other line and is easily done with a macro in 5 keystrokes.
My original solution was
|【Ctrl+f】||move to “puthash”|
|【Ctrl+f】||move after space|
|【Ctrl+7 Ctrl+f】||move after strings|
|【Meta+d Meta+d】||delete “xmsi-abrvs”|
|【Ctrl+n】||move to next line|
|【Ctrl+Shift+Delete】||delete entire line|
|【Meta+0 F4】||end macro and execute|
That’s 28 keystrokes (not 29; I think I shaved off another by combining the end macro and execute). Notice that deleting the extra lines takes only two additional keystrokes. If you don’t worry about deleting the lines, you can do a bit better with
multiple-cursors but then you have to use a macro to get rid of those lines. At least I couldn’t figure out a way to do it from within
Magnar Sveen had a nice trick to shave off two more keystrokes by using
hippie-expand. I tried to integrate that into my solution but after the first time it picked up
xmsi-add-cycle instead of
xmsi-abrvs which resulted in cascading
-adds on subsequent lines. Magnar uses a custom function that looks for the nearest match so his
hippie-expand trick might have worked with a macro for him.
Fuco had a nice approach using his
smartparens package. If anyone else has some good tricks it’s not too late to leave a comment.
If you want to contribute a challenge (please do!) you can mail it to challenges at the domain of this blog.