Type: C-x r k

The rectangle is deleted; it's in a special rectangle kill buffer.
Once again, when you mark a rectangle, you put the cursor on the upper-left corner, set the mark, then move to the lower-right corner of the rectangle and over one more space. Emacs expects rectangles to be rectangles. If necessary, it pads an area with spaces to make up the straight line on the right side.
You can move anywhere on the screen and reinsert the rectangle last killed with the yank-rectanglecommand, C-x r y. To put the "Hours" column on the right side of the table, we move the cursor following the cell phone column.
Place the cursor following Cell
and press M-10 Spaceto move to a good location to paste the "Hours" column:

Move the cursor to where we want to reinsert the rectangle.
Type: C-x r y

Emacs inserts the rectangle we killed earlier.
Emacs inserts the rectangle exactly where you tell it to. We moved past the cell phone column and then added some space between the cell phone and hours columns. Otherwise, Emacs would have blithely inserted the hours column into the middle of the cell phone column. Note that there's no equivalent of the kill ring for rectangles. You can yank only the most recent rectangle. [38]
Killing and yanking rectangles requires practice. Once you get the hang of the procedure, it is an easy way to edit tables and other column-dependent material.
A few other commands create blank rectangles. For example, let's say we want to put four more spaces between the cell phone and hours columns. To do this, we set the mark, move to the bottom of the column, move forward four spaces, then type C-x r o(for open-rectangle). This command inserts a blank rectangle and pushes the remaining text to the right.
Move the cursor to the H
in Hours
and type C-Space

Emacs sets the mark at the upper-left corner of the rectangle.
Now we need to define the amount of space we want to insert. Move down to the bottom of the rectangle (the "Alvin" line) and then move to the hyphen between 6:00
and 3:00
.
Move the cursor following 6:00
.

The lower right corner of the rectangle is defined.
Finally, type C-x r oto add the new space to the table.
Type C-x r o

Emacs inserts a blank rectangle that is four spaces wide. It moves the rest of the table to the right.
The clear-rectanglecommand wipes out text, leaving a blank rectangle in its place. It's just as though you had erased a column on a blackboard. Like the blackboard column, the text column that is wiped out is gone, not stored in the rectangle kill buffer. To continue with our example, let's say that after reviewing the schedule, all those involved agreed that they'd rather not have their cell phones listed.
Move the cursor to the C
in Cell
and type C-space.

The upper-left corner of the rectangle to be cleared is marked.
Move to the space following the last phone number and type: C-x r c

The clear-rectanglecommand removes the "Cell Phone" column and leaves a blank space in its place.
As you can see, the spacing of our table still isn't perfect; you'd probably want to use the delete-rectanglecommand [39]to delete the extra space between the second and the third columns. To delete the blank space without storing it, start by moving the cursor to the space following the longest email address and press C-Spaceto set the mark, then move to the opposite corner of the box you want to delete and type C-x r d.
On the header line, move to the column after the longest email address and press C-Space

The upper-left corner of the rectangle to be deleted is marked.
Move a few spaces before 6:00 on the last line and type C-x r d

The delete-rectanglecommand deletes the blank space.
If you're doing some really fancy table editing, being able to store several rectangles is helpful. That way, you can have every column as a rectangle, as well as having a rectangle for the exact amount of blank space to put between each column. You can store rectangles in registers by typing C-x r r r
where r
is any alphanumeric character, including punctuation. To insert a rectangle you've stored, type C-x r i r
. Registers don't persist between sessions.
Table 7-5lists rectangle commands.
Table 7-5. Rectangle commands
Keystrokes |
Command name |
Action |
C-x r k |
kill-rectangle |
Delete a rectangle and store it. |
C-x r d |
delete-rectangle |
Delete a rectangle and do not store it. |
C-x r y |
yank-rectangle |
Insert the last rectangle killed. |
C-x r c |
clear-rectangle |
Using spaces, blank out the area marked as a rectangle and do not store it. |
C-x r o |
open-rectangle |
Insert a blank rectangle in the area marked. |
C-x r r r |
copy-rectangle-to-register |
Copy rectangle to register r (where r is any character) . |
C-x r i r |
insert-register |
Insert rectangle from register r (where r is any character). |
( none ) |
delete-whitespace-rectangle |
If a rectangle includes initial whitespace, deletes it, narrowing rectangle. |
C-x r t string Enter |
string-rectangle |
Change contents of marked rectangle to string (if string is narrower or wider than rectangle, dimensions change accordingly). |
( none ) |
string-insert-rectangle |
Prompts for string and inserts rectangle. |
7.5.1 CUA Rectangle Editing
Читать дальше