Assume I have a text file with content
1
123
12
12345
If I want to add an 'a' in the beginning of each line I can simply use string-rectangle (C-x r t), but what if I want to append an 'a' to the end of each line, after which the file should become
1a
123a
12a
12345a
Thanks.
You could use replace-regexp
for this purpose, with the $
regexp metacharacter that matches end-of-line. Go to the start of the buffer, and then do M-x replace-regexp
, and answer $
and (your text) to the two prompts.
Or, in emacs-speak, for your specific example of adding a
:
M-< M-x replace-regexp RET $ RET a RET