Friday, 8 February 2013

Rectangles and Emacs

Being able to kill and yank rectangles in text is an incredibly handy tool -- one of those tricks you can't imagine is useful, until you learn about it, and then, your life is incomplete without it.

Say you have:

aaa  bbb ccc
aaa  bbb ccc
aaa  bbb ccc

and you want to move the 'b' block.  So you mark from the first bold b to the last bold b (this looks like you're marking the entire block, but fret not) and type: C-x r k.  This deletes the block and closes the gap.

Now you move to where you want the top left corner of the b block to go, make 3 lines of space below and type  C-x r y, to retrieve the 'b' block and the job is done.

Happy editing!