Emacs Rectangle Editing quick help

Enter picture mode (ESC-x picture-mode)

Marking rectangle

  • Go to top left corner, press CTRL-Space.
  • Go to bottom right, press CTRL-x-x (This selects the rectangle)

Working on rectangle

  • Press CTRL-x-r-k to kill the rectangle (and make it available as 'last-killed-rectangle')
  • Press CTRL-x-r-d to delete the rectangle
  • Press CTRL-x-r-y to yank 'last-killed-rectangle' with its top right at the mark.
  • Press ESC-x-clear-rectangle to fill the rectangle with spaces.

Finally quit the picture mode with CTRL-c-c

Related posts:

  1. Quick tip – how to extract audio from youtube videos

Tags:

  1. Vaibhav Mahimkar’s avatar

    Thanks for the helpful commands. However the CTRL-c-c doesnt quit the mode, I used ESC thrice instead
    -Vaibhav

    Reply

  2. Luca Martini’s avatar

    I think that using picture mode is not necessary.
    You could simply select the text as usual and then use the rectangle commands.

    Luca

    Reply

  3. amit’s avatar

    Vaibhav: I tried on gnu emacs and xemacs, in both, I was able to quit picture mode by CTRL-c-c. Maybe your environment has unbounded the key combination or bound it to something else. Try full commands instead of keystrokes: i.e. ESC-x-kill-rectangle ESC-x-delete-rectangle , ESC-x-yank-rectangle and ESC-x-clear-rectangle.

    Luca: Without picture mode, you cannot select a rectangle, only multiple lines. (Update it seems you can still use the full commands, but you lose the keybindings)

    Reply

Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>