- Related pages
Emacs macros allows us to record sequence of keyboard keystrokes, mouse actions, menu actions that is bound to an Emacs command. It allows us to record these actions and repeat them when needed.
Creating a new macro #
C-x (starts recording a macro
C-x )stops recording a macro
C-x eexecutes the macro
C-u 37 C-x eexecutes the macro 37 times
C-u 0 C-x eexecutes the macro an infinite number of times until EOF.
Create a macro to remove the
- from the following fruit list and replace it
+ (org-mode has still already setup, but for learning purpose, let’s
do it with a macro).
Place the cursor the
banana section and start recording a macro. Remove the
- from Banana and replace it with
+, move to the next line (
and stop recording the macro. Run
C-u 0 C-x e to run the macro until EOF.
It is important to stop defining a macro at a similar position to where you
started it. Executing
apply-macro-to-region-lines applies the last-defined
keyboard macro to each of the lines of a region
- EmacsWiki - Keyboard macros
- elmacro - Shows keyboard macros or latest interactive commands as emacs lisp
- GNU Emacs - Keyboard Macros
- Emacs keyboard macros (info)