Coding Macros Can Save the Day
Repetitive tasks make programming boring. And they’re close cousins of “ctrl-c-ctrl-v-coding”, where DRY violations may be seen as productivity enhancements, instead of real maintenance killers.
Knowing a coding editor really well is an often underestimated programming ability. Good tools have support for macros, that help to automate text manipulation (sometimes, in very creative ways). They can save the day.
Using GNU Emacs below, a tiny example of what can be accomplished with macros is shown, in a typical development scenario (switch statement construction from constants).
Following screencast was captured with recordMyDesktop, a nice Linux tool. HandBrake did the final H.264/MPEG-4_AVC encoding.
Everything is keyboard based. Key-binding hints were not included as annotations (pretty standard Emacs macro stuff, with F3, F4, C-k, C-s, etc):
Note the strange enumeration values. They were chosen to make normalization hard, almost ruling out any table lookup attempt (for the sake of macro usage motivation). Also, no regex stuff was applied, making it easier to watch and “feel” the manipulations.
I hope this opens your mind/eyes.
FOLLOW-UP (01/03/2015): you may also enjoy Coding Regexps Can Also Save the Day