Here are some commands for setting the mark:
The most common way to set the mark is with C-SPC
set-mark-command)5. This sets the mark where point is,
and activates it. You can then move point away, leaving the mark
For example, suppose you wish to convert part of the buffer to upper
case. To accomplish this, go to one end of the desired text, type
C-SPC, and move point until the desired portion of text is
highlighted. Now type C-x C-u (
converts the text in the region to upper case, and then deactivates
Whenever the mark is active, you can deactivate it by typing C-g (see Quitting). Most commands that operate on the region also automatically deactivate the mark, like C-x C-u in the above example.
Instead of setting the mark in order to operate on a region, you can also use it to remember a position in the buffer (by typing C-SPC C-SPC), and later jump back there (by typing C-u C-SPC). See Mark Ring, for details.
The command C-x C-x (
the positions of point and the mark. C-x C-x is useful when you
are satisfied with the position of point but want to move the other
end of the region (where the mark is). Using C-x C-x a second
time, if necessary, puts the mark at the new position with point back
at its original position. Normally, if the mark is inactive, this
command first reactivates the mark wherever it was last set, to ensure
that the region is left highlighted. However, if you call it with a
prefix argument, it leaves the mark inactive and the region
unhighlighted; you can use this to jump to the mark in a manner
similar to C-u C-SPC.
You can also set the mark with the mouse. If you press the left mouse button (down-mouse-1) and drag the mouse across a range of text, this sets the mark where you first pressed the mouse button and puts point where you release it. Alternatively, clicking the right mouse button (mouse-3) sets the mark at point and then moves point to where you clicked. See Mouse Commands, for a more detailed description of these mouse commands.
Finally, you can set the mark by holding down the shift key while typing certain cursor motion commands (such as S-RIGHT, S-C-f, S-C-n, etc.). This is called shift-selection. It sets the mark at point before moving point, but only if there is no active mark set via a previous shift-selection or mouse commands. The mark set by mouse commands and by shift-selection behaves slightly differently from the usual mark: any subsequent unshifted cursor motion command deactivates it automatically. For details, see Shift Selection.
Many commands that insert text, such as C-y (
the mark at the other end of the inserted text, without activating it.
This lets you easily return to that position (see Mark Ring). You
can tell that a command does this when it shows ‘
Mark set’ in the
Under X, every time the active region changes, Emacs saves the text in the region to the primary selection. This lets you insert that text into other X applications with mouse-2 clicks. See Primary Selection.
There is no C-SPC
character in ASCII; usually, typing C-SPC on a
text terminal gives the character [email protected]. This key is also bound
set-mark-command, so unless you are unlucky enough to have
a text terminal that behaves differently, you might as well think of
[email protected] as C-SPC.