Monday, May 02, 2005

rectangle select in Emacs

Working with rows & columns (rectangles)

A "rectangle" is one or more columns of text in one or more rows. Commands are available to delete rectangles, fill them with spaces, or cut and paste them.

To delineate a rectangle for a command to work on, set a mark in the first row to the left of the first column (i.e., the top left of the rectangle).

Move the cursor to the last row, then to the right of the last column (i.e. the bottom right of the rectangle).

To delete the rectangle, type Esc-x delete-rectangle

To cut a rectangle, type Esc-x kill-rectangle

To paste a killed rectangle in a new location, move the cursor to wherever the rectangle is to go and type Esc-x yank-rectangle

To replace the contents of a rectangle with spaces, type Esc-x clear-rectangle

To fill the area of the rectangle with spaces and push the original rectangle right, type Esc-x open-rectangle

4 comments:

Anonymous said...

Woo, nice. Thank you, you were the first hit for deleting rectangles..

Anonymous said...

Great. You were the second result for the Google query "emacs column edit". I needed open-rectangle to shift a python block to the right. Thank you very much.

Anonymous said...

Thank you. You were first result for "emacs selecting column" query on Google.

Ganesh said...

Thanks for the steps. let me make it clear for the novices trying it first time ,

1. Move the cursor to a random part and press " Ctrl+< Space >"

Ex: copy and paste the above lines to emacs

" Thanks for the steps. let me make < new line > it clear for the novices trying it first time ,"

move cursor to 's' in 'steps' and press Ctrl+Space

2. Using the arrow keys select the bottom right corner of the region. Say go to 's' in 'novices' ( Now, the cursor will be blinking in that point, let it be) Now type the "Crtl+x r r r " < press x holding Crtl then leave it, now press r 3 times >

3. Now, Press "Ctrl+g" ( to avoid further marking ) To paste this, move to a place where you wish to paste the content and press "Ctrl+x r g r " < press x while holding Ctrl and then press 'r' without holding any key then type 'g' then 'r' >

This will paste the above selected region.

output:

or the steps. l
for the novice


-Ganesh