This post is about how to increment and paste a counter while executing an emacs macro. For some reason, this is not easy to find on the Internet. So I'll write it down on my blog since I keep forgetting.
- Set the start point of the counter
M-: (setq i 1)
- Start recording macro with
C-x (
- Insert index as needed with
C-u M-: i
- Increment index when finished with macro
M-: (setq i (+ i 1))
- Complete macro with
C-x )
- Execute Macro with
C-x e
To execute the macro multiple times, use
ALT-(# of times) C-x e
.
No comments:
Post a Comment