Next: , Previous: , Up: Top   [Contents][Index]

9 Selecting Text

Many Emacs commands operate on an arbitrary contiguous part of the current buffer. You can select text in two ways:

9.1 The Mark and the Region

To specify the text for a command to operate on, set the mark at one end of it, and move point to the other end. The text between point and the mark is called the region. You can move point or the mark to adjust the boundaries of the region. It doesn’t matter which one is set first chronologically, or which one comes earlier in the text.

Once the mark has been set, it remains until it is set again at another place. The mark remains fixed with respect to the preceding character if text is inserted or deleted in a buffer. Each Emacs buffer has its own mark; when you return to a buffer that had been selected previously, it has the same mark it had before.

Many commands that insert text, such as C-y (yank) and M-x insert-buffer, position the mark at one end of the inserted text—the opposite end from where point is positioned, so that the region contains the text just inserted.

Aside from delimiting the region, the mark is useful for marking a spot that you may want to go back to. To make this feature more useful, Emacs remembers 16 previous locations of the mark in the mark ring.

Next: , Previous: , Up: Top   [Contents][Index]