Difference between revisions of "Rectangles"

From WikEmacs
Jump to navigation Jump to search
m (fixed typo)
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
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.
 
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 ==
+
== Command of rectangles ==
  
* C-x r k
+
* {{Keys|C-x r k}} or {{Command|kill-rectangle}}
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”.
* C-x r d
+
* {{Keys|C-x r d}} or {{Command|delete-rectangle}}
Delete the text of the region-rectangle (delete-rectangle).  
+
Delete the text of the region-rectangle.
* C-x r y
+
* {{Keys|C-x r y}} or {{Command|yank-rectangle}}
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.
* C-x r o
+
* {{Keys|C-x r o}} or {{Command|open-rectangle}}
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. This pushes the previous contents of the region-rectangle rightward.  
* C-x r c
+
* {{Keys|C-x r c}} or {{Command|clear-rectangle}}
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.
M-x delete-whitespace-rectangle
+
* {{Command|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>
+
* {{Keys|C-x r t string RET}} or {{Command|string-rectangle}}
Replace rectangle contents with string on each line (string-rectangle).  
+
Replace rectangle contents with string on each line.
* M-x string-insert-rectangle <RET> string <RET>
+
* {{Command|string-insert-rectangle RET string RET}}
 
Insert string on each line of the rectangle.
 
Insert string on each line of the rectangle.
 +
 +
[[Category:Text Editing]]

Latest revision as of 19:50, 20 April 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 rectangles

  • [C-x r k] or M-x kill-rectangle

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

  • [C-x r d] or M-x delete-rectangle

Delete the text of the region-rectangle.

  • [C-x r y] or M-x yank-rectangle

Yank the last killed rectangle with its upper left corner at point.

  • [C-x r o] or M-x open-rectangle

Insert blank space to fill the space of the region-rectangle. This pushes the previous contents of the region-rectangle rightward.

  • [C-x r c] or M-x clear-rectangle

Clear the region-rectangle by replacing all of its contents with spaces.

  • 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] or M-x string-rectangle

Replace rectangle contents with string on each line.

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

Insert string on each line of the rectangle.