In stock Emacs, I would break it into two steps.
Step 1: Insert leading quote
Define a (empty) rectangle consisting of the start of each line. Replace the contents of that (empty) rectangle with a '
.
- At the top of the block, press
C-<SPC>
to set mark
- Navigate to the beginning of the last line
- Use
C-x r t
(string-rectangle
) to insert a '
to each of the lines defined in the rectangle
Step2: Insert a trailing quote
Define a region and replace all line endings in the region with a '
.
- Navigate to the end of the last line with
C-e
- Set mark with
C-<SPC>
- Navigate to the beginning of the first line
- Call
M-x replace-regexp
with $
for the end of the line and '
to replace the end of the line with a trailing quote
What I do in my day-to-day is use evil
with evil-surround
. In that case, it simply becomes ysiw'
. The ys
is the evil-surround
command used to operate on a text object iw
(i.e. inner word
). The quote is then what you surround the inner word with. Altogether, I think of it as "you surround inner word (with) quote".
\(^.*$\)
then, you can wrap the matched group in quotes like this: ` '\1'`.