Emacs: Keyboard Macro Commands
Here's a list of all Keyboard Macro commands.
Record
kmacro-start-macro
【Ctrl+x (】 【C-x C-k s】, 【C-x C-k C-s】-
start record.
- (It relies on the primitive function
start-kbd-macro
) defining-kbd-macro
is an alias ofstart-kbd-macro
.
- (It relies on the primitive function
kmacro-end-macro
【Ctrl+x )】-
end record. (It relies on the primitive function
end-kbd-macro
)
Call
call-last-kbd-macro
-
call the last keyboard macro.
apply-macro-to-region-lines
-
apply last last keyboard macro to each line in text selection.
💡 TIP: to make this useful, you should create a macro that start at beginning of line, and do not move to next line.
kmacro-end-call-mouse
【S-<mouse-3>】-
Move point to the position clicked with the mouse and call last kbd macro
kmacro-call-macro
-
Call the keyboard MACRO that you defined with
kmacro-start-macro
kmacro-end-or-call-macro
【F4】-
End kbd macro if currently being defined; else call last kbd macro
kmacro-end-or-call-macro-repeat
【C-x C-k C-k】-
As
kmacro-end-or-call-macro
but allow repeat without repeating prefix kmacro-end-and-call-macro
【Ctrl+x e】-
call the last keyboard macro. (stop it if still recording)
Store
kmacro-name-last-macro
【C-x C-k n】-
Assign a name to the last keyboard macro defined. (
name-last-kbd-macro
is an alias.) insert-kbd-macro
-
Insert in buffer the definition of kbd macro MACRONAME, as Lisp code.
kmacro-to-register
【C-x C-k x】-
Store the last keyboard macro in register. 〔see Emacs: Copy to Register〕 Call it by calling
jump-to-register
kmacro-bind-to-key
【C-x C-k b】-
When not defining or executing a macro, offer to bind last macro to a key
Edit
edit-kbd-macro
【C-x C-k e】-
Edit a keyboard macro.
edit-last-kbd-macro
-
Edit the most recently defined keyboard macro.
edit-named-kbd-macro
-
Edit a keyboard macro which has been given a name by
name-last-kbd-macro
. kmacro-edit-lossage
【C-x C-k l】-
Edit most recent 300 keystrokes as a keyboard macro
kmacro-edit-macro
【C-x C-k RET】-
As edit last keyboard macro, but without kmacro-repeat property
kmacro-edit-macro-repeat
【C-x C-k C-e】-
Edit last keyboard macro
kmacro-step-edit-macro
【C-x C-k SPC】-
Step edit and execute last keyboard macro
Counter
kmacro-add-counter
【C-x C-k C-a】-
Add the value of numeric prefix arg (prompt if missing) to kmacro-counter
kmacro-insert-counter
【C-x C-k TAB】-
Insert current value of
kmacro-counter
, then increment it by ARG kmacro-set-counter
【C-x C-k C-c】-
Set the value of
kmacro-counter
to ARG, or prompt for value if no argument kmacro-set-format
【C-x C-k C-f】-
Set the format of
kmacro-counter
to FORMAT kmacro-start-macro-or-insert-counter
【F3】-
Record subsequent keyboard input, defining a keyboard macro
View
kmacro-view-macro
-
Display the last keyboard macro
kmacro-view-macro-repeat
【C-x C-k C-v】-
Display the last keyboard macro
kmacro-view-ring-2nd
-
Display the second macro in the keyboard macro ring
Other
kbd-macro-query
【C-x C-k q】, 【C-x q】-
Query user during kbd macro execution.
read-kbd-macro
-
Read the region as a keyboard macro definition.
kmacro-call-ring-2nd
-
Execute second keyboard macro in macro ring
kmacro-call-ring-2nd-repeat
【C-x C-k C-l】-
Execute second keyboard macro in macro ring
kmacro-cycle-ring-next
【C-x C-k C-n】-
Move to next keyboard macro in keyboard macro ring
kmacro-cycle-ring-previous
【C-x C-k C-p】-
Move to previous keyboard macro in keyboard macro ring
kmacro-delete-ring-head
【C-x C-k C-d】-
Delete current macro from keyboard macro ring
kmacro-swap-ring
【C-x C-k C-t】-
Swap first two elements on keyboard macro ring