Emacs Advent Calendar 02: Mark and Region
Many commands act on part of a buffer. To specify this part, one sets the mark at one end and positions point to the other end. The text now enclosed between point an mark is called the region.
Note that point does not necessarily has to come before mark, the region behaves the same either way.
When the mark is set, it becomes activated, as does the region that is
defined by it. An active region is highlighted in the buffer. A region
can be deactivated by the universal canceling command
To set the mark at point press
C-SPC. Now the region can be extended
by moving away point. To correct the position of mark use the command
C-x C-x. This swaps the positions of point and mark and allows the
start of the region to be moved around.
Several commands exist for selecting separate textual objects.
sets the mark at the end of the next word, repeated presses move the
mark forward one word at a time. Similarly
M-h selects the current
C-x h the complete buffer.
When Emacs is operated under X, the text inside the region is saved to primary selection, i.e. it can be inserted into other applications by a click of middle mouse button.
Besides specifying the region, mark has another use: Each activation
of mark pushes its position on the mark ring. To cycle through the
earlier positions of mark, press
C-u C-SPC repeatedly. Manually
pushing a position on the ring is accomplished with the command
C-SPC (which in fact activates the region and then immediately
deactivates it again).
Some commands push a mark position on the ring themselves and indicate it by showing "Mark set" in the echo area.Tags: emacs
This text by Ludger Sandig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.