Difference between revisions of "Rectangles"

From WikEmacs
Jump to: navigation, search
m (Command of rectangles)
m (fixed typo)
 
(One intermediate revision by one user not shown)
Line 17: Line 17:
 
* {{Keys|C-x r c}} or {{Command|clear-rectangle}}
 
* {{Keys|C-x r c}} or {{Command|clear-rectangle}}
 
Clear the region-rectangle by replacing all of its contents with spaces.
 
Clear the region-rectangle by replacing all of its contents with spaces.
{{Command|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.  
* {{Keys|C-x r t string <RET>}} or {{Command|string-rectangle}}
+
* {{Keys|C-x r t string RET}} or {{Command|string-rectangle}}
 
Replace rectangle contents with string on each line.
 
Replace rectangle contents with string on each line.
* {{Command|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 14: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[edit]

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