1.10. Writing Macros

1.10.1. Macro Commands

To Keystrokes Command Name
Start defining a macro C-x ( start-kbd-macro
End macro definition C-x ) end-kbd-macro
Execute last macro defined C-x e call-last-kbd-macro
Execute the last macro defined n times ESC n C-x e digit-argument; call-last- kbd-macro
Execute the last macro defined and then add keystrokes to it C-u C-x ( universal-argument; start-kbd-macro
Name the last macro created (a preface to saving it) ESC x name-last-kbd-macro
Save a named macro in a file ESC x insert-keyboard-macro
Load a named macro ESC x load-file
Execute a named macro ESC macroname
Insert a query in a macro definition C-x q kbd-macro-query
Insert a recursive edit in a macro definition C-u C-x q universal argument; kbd-macro-query
Exit a recursive edit ESC C-c exit-recursive-edit

Get GNU Emacs Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.