Difference between revisions of "Rectangles"

From WikEmacs
Jump to navigation Jump to search
(Created page with "Rectangle commands operate on rectangular areas of the text: all the characters between a certain pair of columns, in a certain range of lines. Emacs has commands to kill rect...")
 
Line 7: Line 7:
 
== Command of rectagnles ==
 
== Command of rectagnles ==
  
C-x r k
+
* C-x r k
 
Kill the text of the region-rectangle, saving its contents as the “last killed rectangle” (kill-rectangle).  
 
Kill the text of the region-rectangle, saving its contents as the “last killed rectangle” (kill-rectangle).  
C-x r d
+
* C-x r d
 
Delete the text of the region-rectangle (delete-rectangle).  
 
Delete the text of the region-rectangle (delete-rectangle).  
C-x r y
+
* C-x r y
 
Yank the last killed rectangle with its upper left corner at point (yank-rectangle).  
 
Yank the last killed rectangle with its upper left corner at point (yank-rectangle).  
C-x r o
+
* 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.  
 
Insert blank space to fill the space of the region-rectangle (open-rectangle). This pushes the previous contents of the region-rectangle rightward.  
C-x r c
+
* C-x r c
 
Clear the region-rectangle by replacing all of its contents with spaces (clear-rectangle).  
 
Clear the region-rectangle by replacing all of its contents with spaces (clear-rectangle).  
 
M-x delete-whitespace-rectangle
 
M-x delete-whitespace-rectangle
 
Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.  
 
Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.  
C-x r t string <RET>
+
* C-x r t string <RET>
 
Replace rectangle contents with string on each line (string-rectangle).  
 
Replace rectangle contents with string on each line (string-rectangle).  
M-x string-insert-rectangle <RET> string <RET>
+
* M-x string-insert-rectangle <RET> string <RET>
 
Insert string on each line of the rectangle.
 
Insert string on each line of the rectangle.

Revision as of 14:59, 28 March 2012

Rectangle commands operate on rectangular areas of the text: all the characters between a certain pair of columns, in a certain range of lines. Emacs has commands 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 much the same way as 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.

Command of rectagnles

  • C-x r k

Kill the text of the region-rectangle, saving its contents as the “last killed rectangle” (kill-rectangle).

  • C-x r d

Delete the text of the region-rectangle (delete-rectangle).

  • C-x r y

Yank the last killed rectangle with its upper left corner at point (yank-rectangle).

  • 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.

  • C-x r c

Clear the region-rectangle by replacing all of its contents with spaces (clear-rectangle). M-x delete-whitespace-rectangle Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.

  • C-x r t string <RET>

Replace rectangle contents with string on each line (string-rectangle).

  • M-x string-insert-rectangle <RET> string <RET>

Insert string on each line of the rectangle.