Department of Engineering

IT Services

Macros

To avoid repetitive key sequences you can use macros. Suppose you wanted to append `.old' to the next 50 words of text. Type

  C-x (

to start defining a macro, then perform what you want the macro to do on the first word,

  M-f .old

(M-f goes to the end of the current word) then end the macro definition using

  C-x )

C-x e will execute this, the last defined macro, once. To perform it 48 more times, use C-u 48 C-x e.

To give this macro a name, use

  M-x name-last-kbd-macro RET <macroname> RET

You can now use M-x <macroname> to call the macro, or use global-set-key to bind a key to the macro (see the keybinding page).