Next: Registers Prev: Accumulating Text Up: Top


   The rectangle commands operate on rectangular areas of the text: all
the characters between a certain pair of columns, in a certain range of
lines. Commands are provided to kill rectangles, yank killed rectangles,
clear them out, fill them with blanks or text, or delete them. Rectangle
commands are useful with text in multicolumn formats, and for changing
text into or out of such formats.

   When you must specify a rectangle for a command to work on, you do it
by putting the mark at one corner and point at the opposite corner.  The
rectangle thus specified is called the "region-rectangle" because you
control it in about the same way the region is controlled.  But
remember that a given combination of point and mark values can be
interpreted either as a region or as a rectangle, depending on the
command that uses them.

   If point and the mark are in the same column, the rectangle they
delimit is empty.  If they are in the same line, the rectangle is one
line high.  This asymmetry between lines and columns comes about
because point (and likewise the mark) is between two columns, but within
a line.

`C-x r k'
     Kill the text of the region-rectangle, saving its contents as the
     "last killed rectangle" (`kill-rectangle').

`C-x r y'
     Yank the last killed rectangle with its upper left corner at point

`C-x r o'
     Insert blank space to fill the space of the region-rectangle
     (`open-rectangle').  This pushes the previous contents of the
     region-rectangle rightward.

`M-x delete-rectangle'
     Delete the text of the region-rectangle without saving it in any
     special way.

`M-x clear-rectangle'
     Clear the region-rectangle by replacing its contents with spaces.

`M-x string-rectangle RET STRING RET'
     Insert STRING on each line of the region-rectangle.

   The rectangle operations fall into two classes: commands deleting and
inserting rectangles, and commands for blank rectangles.

   There are two ways to get rid of the text in a rectangle: you can
discard the text (delete it) or save it as the "last killed" rectangle.
The commands for these two ways are `M-x delete-rectangle' and `C-x r
k' (`kill-rectangle').  In either case, the portion of each line that
falls inside the rectangle's boundaries is deleted, causing following
text (if any) on the line to move left into the gap.

   Note that "killing" a rectangle is not killing in the usual sense;
the rectangle is not stored in the kill ring, but in a special place
that can only record the most recent rectangle killed.  This is because
yanking a rectangle is so different from yanking linear text that
different yank commands have to be used and yank-popping is hard to
make sense of.

   Yanking a rectangle is the opposite of killing one.  Point specifies
where to put the rectangle's upper left corner.  The rectangle's first
line is inserted there, the rectangle's second line is inserted at a
point one line vertically down, and so on.  The number of lines affected
is determined by the height of the saved rectangle.

   To yank the last killed rectangle, type `C-x r y'
(`yank-rectangle').  This can be used to convert single-column lists
into double-column lists; kill the second half of the list as a
rectangle and then yank it beside the first line of the list.

   You can also copy rectangles into and out of registers with `C-x r r
R' and `C-x r i R'.  Note: Rectangle Registers.

   The command `M-x string-rectangle' is similar to `C-x r o', but it
inserts a specified string instead of blanks.  You specify the string
with the minibuffer.  Since the length of the string specifies how many
columns to insert, the width of the region-rectangle does not matter
for this command.  What does matter is the position of the left edge
(which specifies the column position for the insertion in each line)
and the range of lines that the rectangle occupies.  The previous
contents of the text after the insertion column are pushed rightward.

   There are two commands for making with blank rectangles: `M-x
clear-rectangle' to blank out existing text, and `C-x r o'
(`open-rectangle') to insert a blank rectangle.  Clearing a rectangle
is equivalent to deleting it and then inserting a blank rectangle of
the same size.

automatically generated by info2www