4 ms·
You should check out the EmacsWiki macro tricks page: http://www.emacswiki.org/emacs/KeyboardMacrosTricks http://www.emacswiki.org/emacs/KeyboardMacrosTricks
by jfager 15y ago
You should check out the EmacsWiki macro tricks page:
http://www.emacswiki.org/emacs/KeyboardMacrosTricks http://www.emacswiki.org/emacs/KeyboardMacrosTricks
From there:
If you want to produce this list:
test1
test2
test3
...
Do like this:
C-x r n q (store the number 1 in register q)
C-x ( (start macro recording)
test C-x r i q (insert contents of register q)
C-x r + q (increment register q by 1)
RET (new line)
C-x ) (stop macro recording)
- jcsalterego 15y agoOw, that hurts my brain more than usual. How would one leverage registers with text instead of incremental numbers? (I will have to RTFW later.)
- calibraxis 15y agoThe easy way I do it is to make however many copies of "test0" I want, then make a trivial throwaway macro where I move my cursor to the number I want to increment, and hit M-x rolling-increment-number-at-point. (Of course with autocomplete...) Here's my definitions: (defvar *rolling-counter* 0) (defun rolling-increment-number-at-point () (interactive) (incf *rolling-counter*) (skip-chars-backward "0123456789") (or (looking-at "[0123456789]+") (error "No number at point")) (replace-match (number-to-string (+ *rolling-counter* (string-to-number (match-string 0)))))) (defun clear-rolling-history () (interactive) (setf *rolling-counter* 0))