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

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:
      M-x
    At the prompt, enter:
      set-mark
  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:
      M-x
    At the prompt, enter:
      kill-rectangle
  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 2016-11-30 13:09:29.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.