Yes, it's possible with multiple-cursors
.

- Let's say you have atleast 5 consecutive empty lines.
- With the cursor at the topmost empty line, create 5 multiple cursors by keeping on hitting
C->
(default binding for mc/mark-next-like-this
).
- Type the common variable prefix:
x_
as per your example.
- Insert numbers starting with the prefix you specify (default starting number is
0
) to mc/insert-numbers
. For your example, you would do C-u 1 M-x mc/insert-numbers
.
- Hit
C-g
or RET
to exit multiple cursors mode.
Alternative way using the tiny
package
Type m1\n5|x_%d
and M-x tiny-expand
.
The best part is that you can undo
and get back to that expression, tweak it, M-x tiny-expand
, repeat, ..
tiny
syntax cheat-sheet
mBSEO|F
││││--
│││││└──> (optional) Format - %x | 0x%x | %c | %s | %(+ x x) | %014.2f | %03d
││││└───> (optional) Pipe character used if Format specified for reading clarity
│││└────> (optional) Lisp Operation - *xx | (* x x) | (+ x ?A) | *2+3x | (* 2 (+ 3 x))
││└─────> End value
│└──────> (optional) Separator - Space | , | \n (default=Space)
└───────> (optional) Begin value (default=0)
- No space allowed between 'm' and 'B'
- No space allowed between 'E' and 'O'