Rectangles

I never use the rectangle commands as often as I should.

Here’s my shopping list:

  • Bread
  • Cheese
  • Milk
  • Yoghurt

I want to make the above into a list. There are all sorts of ways I could so this, one way is to use the string-rectangle command. Set (or highlight) the region to zero width in front of the list and then C-x r t – to insert a dash before each of the words.

You can use the kill-rectangle command to remove unwanted bullet points (particularly useful when importing text from PDFs)

Set the region to cover the bullet symbols and then C-x r k to kill the rectangle. Don’t forget you can C-x r y yank that rectangle back.

C-x r o or open-rectangle is a quick way to indent a block of text to where you want it, especially if you can’t remember the other commands.

And lastly C-x r c will clear a rectangular space. I can’t remember ever using that one, to be honest…

If you find pressing C-x r a keystroke too far, read this post on remapping C-x r  to C-`

Summary of Commands

C-x r k    Kill rectangle
C-x r y     yank last killed rectangle
C-x r c     Clear rectangle
C-x r o     open rectangle and shift text right
C-x r t spoons  fill rectangle with spoons
C-x r r q   Copy rectangle to register q
C-x r i q   Insert rectangle from register q

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.