manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.1 Setting the Mark

Here are some commands for setting the mark:

C-<SPC>

Set the mark where point is (set-mark-command).

C-@

The same.

C-x C-x

Interchange mark and point (exchange-point-and-mark).

Drag-Mouse-1

Set point and the mark around the text you drag across.

Mouse-3

Set the mark where point is, then move point to where you click (mouse-save-then-kill).

For example, suppose you wish to convert part of the buffer to upper case, using the C-x C-u (upcase-region) command, which operates on the text in the region. You can first go to the beginning of the text to be capitalized, type C-<SPC> to put the mark there, move to the end, and then type C-x C-u. Or, you can set the mark at the end of the text, move to the beginning, and then type C-x C-u.

The most common way to set the mark is with the C-<SPC> command (set-mark-command). This sets the mark where point is. Then you can move point away, leaving the mark behind.

There are two ways to set the mark with the mouse. You can drag mouse button one across a range of text; that puts point where you release the mouse button, and sets the mark at the other end of that range. Or you can click mouse button three, which sets the mark at point (like C-<SPC>) and then moves point where you clicked (like Mouse-1).

Using the mouse to mark a region copies the region into the kill ring in addition to setting the mark; that gives behavior consistent with other window-driven applications. If you don't want to modify the kill ring, you must use keyboard commands to set the mark. See section Mouse Commands for Editing.

When Emacs was developed, terminals had only one cursor, so Emacs does not show where the mark is located–you have to remember. If you enable Transient Mark mode (see below), then the region is highlighted when it is active; you can tell mark is at the other end of the highlighted region. But this only applies when the mark is active.

The usual solution to this problem is to set the mark and then use it soon, before you forget where it is. Alternatively, you can see where the mark is with the command C-x C-x (exchange-point-and-mark) which puts the mark where point was and point where the mark was. The extent of the region is unchanged, but the cursor and point are now at the previous position of the mark. In Transient Mark mode, this command also reactivates the mark.

C-x C-x is also useful when you are satisfied with the position of point but want to move the other end of the region (where the mark is); do C-x C-x to put point at that end of the region, and then move it. Using C-x C-x a second time, if necessary, puts the mark at the new position with point back at its original position.

For more facilities that allow you to go to previously set marks, see The Mark Ring.

There is no such character as C-<SPC> in ASCII; when you type <SPC> while holding down <CTRL> on a text terminal, what you get is the character C-@. This key is also bound to set-mark-command–so unless you are unlucky enough to have a text terminal where typing C-<SPC> does not produce C-@, you might as well think of this character as C-<SPC>.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.