Xah Lee has a nice updated post on working with rectangles and some other loosely related matters. Every time I see these commands I think how useful they are and then promptly forget about them. I’m going to make an effort to try to use them more often to set them in my mind.
I especially like the replace-rectangle
and string-insert-rectangle
commands that let you replace the rectangle or add text to the beginning of each line of the rectangle. A sometimes useful related command is kill-rectangle
that just deletes the rectangle (and puts it in the kill ring).
Lee also presents a bit of Elisp that shows how to copy a rectangle into the system’s clipboard. I like this not because it’s something I want to do but because of the techniques he uses to copy the rectangle into the kill buffer. It’s something that looks like it could be useful in other contexts.
SUMMARY OF COMMANDS
COMMAND | KEY BINDING |
---|---|
replace-rectange |
【Ctrl+x r t】 |
string-insert-rectangle |
Unbound |
kill-rectangle |
【Ctrl+x r k】 |