ARCHIVED: How do I use Emacs to cut and paste a rectangular region (columns or fields) of text?

This content has been archived, and is no longer maintained by Indiana University. Resources linked from this page may no longer be available or reliable.

Cutting and pasting rectangular regions of a document is especially useful when you need to edit the contents of multi-column tables. To perform this operation in Emacs, follow these steps:

  1. Move the cursor to the upper-left corner of the area you want to cut.
  2. Set the mark by pressing C-@ or C-SPC. If your terminal does not allow this keystroke, you can also set the mark by pressing:
    At the prompt, enter:
  3. Move the cursor one space beyond the lower-right corner of the region you are going to cut.
  4. Delete the rectangle into the kill buffer by pressing:
    At the prompt, enter:
  5. Move the cursor to the upper-left corner of the area where you want to paste the rectangle.
  6. Retrieve your text by entering:
      M-x yank-rectangle

Your rectangle of text will now appear at the new location you have chosen.

Note: If you paste your rectangle of text to the far right side of your document, Emacs may insert tabs to fill the text between the moved rectangle and the text that was previously at the right side of the document.

At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?

This is document afhg in the Knowledge Base.
Last modified on 2018-01-18 10:00:11.

Contact us

For help or to comment, email the UITS Support Center.