17.7 Stepwise Editing a Keyboard Macro
You can interactively replay and edit the last keyboard macro, one command at a time, by typing C-x C-k SPC (kmacro-step-edit-macro). Unless you quit the macro using q or C-g, the edited macro replaces the last macro on the macro ring.
This macro editing feature shows the last macro in the minibuffer together with the first (or next) command to be executed, and prompts you for an action. You can enter ? to get a summary of your options. These actions are available:
SPCandyexecute the current command, and advance to the next command in the keyboard macro.n,d, andDELskip and delete the current command.fskips the current command in this execution of the keyboard macro, but doesn’t delete it from the macro.TABexecutes the current command, as well as all similar commands immediately following the current command; for example,TABmay be used to insert a sequence of characters (corresponding to a sequence ofself-insert-commandcommands).ccontinues execution (without further editing) until the end of the keyboard macro. If execution terminates normally, the edited macro replaces the original keyboard macro.C-kskips and deletes the rest of the keyboard macro, terminates step-editing, and replaces the original keyboard macro with the edited macro.qandC-gcancels the step-editing of the keyboard macro; discarding any changes made to the keyboard macro.i key… C-jreads and executes a series of key sequences (not including the finalC-j), and inserts them before the current command in the keyboard macro, without advancing over the current command.I key…reads one key sequence, executes it, and inserts it before the current command in the keyboard macro, without advancing over the current command.r key… C-jreads and executes a series of key sequences (not including the finalC-j), and replaces the current command in the keyboard macro with them, advancing over the inserted key sequences.R key…reads one key sequence, executes it, and replaces the current command in the keyboard macro with that key sequence, advancing over the inserted key sequence.a key… C-jexecutes the current command, then reads and executes a series of key sequences (not including the finalC-j), and inserts them after the current command in the keyboard macro; it then advances over the current command and the inserted key sequences.A key… C-jexecutes the rest of the commands in the keyboard macro, then reads and executes a series of key sequences (not including the finalC-j), and appends them at the end of the keyboard macro; it then terminates the step-editing and replaces the original keyboard macro with the edited macro.