Emacs insert series

In Excel you can easily fill in a column with a list of values.
Some times also in Emacs you my need to write down a bunch of similar code.
The dotimes function with the “elsp eval”
M-x : (Esc + : on windooze)
will solve your trouble easily.
Try out this code on scratch buffer:

[text]
(dotimes (i 15) (insert (format "Guys born on %04d will be %02d years old on 2017 \n" (+ 1970 i) (- 2017 (+ 1970 i)) )))
[/text]

and live happy

Also, in a regexp replace you can use the ‘ \, ‘ syntax to push an elisp expression:
For instance enter \,(1+ #1), where , indicates that an elisp form to substitute follows, 1+ is an increment function, and #1 is the first captured match text, interpreted as a number.

Example of camel case transformer:

[text]
M-x replace-regexp
Replace regexp: \(\w\)\(\w+\)Value(
Replace regexp with: get\,(upcase \1)\2(
[/text]

Leave a Reply