Emacs Keyboard Macros

There’s another nice video over at Emacs Elements. This time it’s about using keyboard macros in Emacs. Keyboard macros really are a super power and it’s worth spending a few minutes learning some of the details.

Most of us know that you start defining a macro with F3 (or the older Ctrl+x () and end it with F4 (or Ctrl+x )). But wait: there’s more. You can also add a counter that gets incremented each time the macro is run. The video gives a simple example but it’s much more useful than the video suggests.

One of the most obscure but potentially useful features is the ability to enter recursive editing mode in the middle of a macro. That allows you to enter custom text or even do custom editing for each invocation of the macro. It can be tremendously useful in real world editing.

One thing I learned from the video is that you can apply a macro to a region. The rules are subtly different: you edit the first line and then the changes are applied to the other lines in the region. There’s no need to move to the beginning of the next line.

The video is 16 and a quarter minutes so it should be easy to fit in. It’s definitely worth a few minutes of your time. If you aren’t already using keyboard macros, you’re missing out on a lot of power.

This entry was posted in General and tagged . Bookmark the permalink.