This is in a similar vein to my earlier question: Removing the last n characters from every line in an emacs buffer. The comments made there all apply here.
Suppose I want to either
insert the same text string on every line of an emacs buffer at the same place (k characters from the beginning)
or
remove n characters from every line of an emacs buffer starting at the same place (k characters from the beginning)
could I do that using replace-regex
and if so, how? If not, is there some other way?
EDIT: To be clear, I'd like a solution which uses point and mark to define the location of insertion, as well as one that uses a specific n.
EDIT 2: Thanks to alexis for an answer based on replace-regex
. Gilles pointed out that one could use the rectangle commands, e.g. string-rectangle
. Though I use these commands regularly, it did not occur to me to use it here. Dumb of me.