How can I use emacs string-insert-rectangle operation to add a vector of numbers to a series of lines? For example, I\'ve got this shortened version of a bunch of text entri
You can use query-replace-regexp
directly, by adding a new column with the match count \#
.
The matches look for 3 columns separated by spaces, which will be stored in submatch strings \1
to \3
. The replaced string adds a new column using the match count.
Version 1 (simpler, but starts at 0):
M-x query-replace-regexp RET
^\(\w+\)\ +\(\w+\)\ +\(\w+\)$ RET
\1 \2 id\# \3 RET
Note I used spaces for matching and replacing. You can use tabs instead.
Version 2 (uses lisp to customize the row count with the +1
function):
M-x query-replace-regexp RET
^\(\w+\)\ +\(\w+\)\ +\(\w+\)$ RET
\,(format "%s %s id%d %s" \1 \2 (+1 \#) \3) RET