Emacs: Keyboard Macro Commands

By Xah Lee. Date: .

here's a list of all Emacs: Keyboard Macro commands.

To list them, Alt+x apropos-command then type “macro”.

Most Useful Keyboard Macro Commands

here's the most useful ones:

kmacro-start-macroCtrl+x (】 【C-x C-k s】, 【C-x C-k C-s】
start record.
(It relies on the primitive function start-kbd-macro)
kmacro-end-macroCtrl+x )
end record.
(It relies on the primitive function end-kbd-macro)
kmacro-end-and-call-macroCtrl+x e
call the last keyboard macro. (stop it if still recording)
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.
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.)

All Other Keyboard Macro Commands

defining-kbd-macro M-x ... RET
Record subsequent keyboard input, defining a keyboard macro.
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'.
insert-kbd-macro
Insert in buffer the definition of kbd macro MACRONAME, as Lisp code.
kbd-macro-query 【C-x C-k q】, 【C-x q】
Query user during kbd macro execution.
name-last-kbd-macro
Assign a name to the last keyboard macro defined.
read-kbd-macro
Read the region as a keyboard macro definition.
kmacro-add-counter 【C-x C-k C-a】
Add the value of numeric prefix arg (prompt if missing) to `kmacro-counter'
kmacro-bind-to-key 【C-x C-k b】
When not defining or executing a macro, offer to bind last macro to a key
kmacro-call-macro
Call the keyboard MACRO that you defined with kmacro-start-macro
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-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-end-call-mouse 【S-<mouse-3>】
Move point to the position clicked with the mouse and call last kbd macro
kmacro-end-or-call-macroF4
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-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-counterF3
Record subsequent keyboard input, defining a keyboard macro
kmacro-step-edit-macro 【C-x C-k SPC】
Step edit and execute last keyboard macro
kmacro-swap-ring 【C-x C-k C-t】
Swap first two elements on keyboard macro ring
kmacro-to-register 【C-x C-k x】
Store the last keyboard macro in register R
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

Emacs Keyboard Macro

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Font

Split Window

File

Buffer

Find Replace

Copy/Paste

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc