Back in September I made the assertion that every programmer should be familiar with an editor that can record keyboard macros, even if it’s not the only editor they use. The other day I recorded a little video demonstrating why ad-hoc keyboard macros are so great. It’s not a feature you need every day, but when you do need it it can be a lifesaver.
I’m using Emacs in the video, but this isn’t to say you should use Emacs specifically. Several editors have this capability. The only thing I demonstrate that may not be available in those editors is the ability to easily display and edit the recorded macro.
httpv://youtube.com/watch?v=3CkohUDAYaw
If you prefer you can download the video.
A subtle point that’s easy to miss: in order for macro recordings to be effective, the editor really needs to support semantic keyboard commands: e.g. “forward one word”, “go to beginning of line”, “forward one expression”, “move forward to the next underscore”, “lowercase word” and so on. Without semantic commands you’d just be recording character-by-character edits which wouldn’t generalize very well.
Yes, yes, YES. A million times yes. Simple macros are super handy, and I can't imagine serious programming in an editor without them.
For what it's worth, while it doesn't have a nice little macro-edit-mode like emacs (AFAIK), vim supports easily displaying its macros, since vim macros are simply stored in registers (which are also used by 'y'ank, 'd'elete, 'p'ut, 'c'hange, etc). So, if you recorded a macro like so: qqifoobar<esc>q, then the macro is in your “q register. You can replay it via @q, view it via :registers q, or even put it (into a scratch buffer) with “qp, edit it there, and then yank it back via “qyy. There are some register editing plugins available, but I've never bothered with them, so can't comment.</esc>
I think Emacs registers can contain macros too; I haven't dug into that aspect. Anyway, thanks for the info!
Manual on the macros. http://www.gnu.org/software/em…
Save, edit, name, bind to keys…
Thanks!
Once I had to extract a bunch of information from a word document to a parseable format… Vim macros saved my life that day!