Next: The Mark Ring, Previous: Commands to Mark Textual Objects, Up: The Mark and the Region [Contents][Index]
Once you have a region, here are some of the ways you can operate on it:
Some commands have a default behavior when the mark is inactive, but
operate on the region if the mark is active. For example, M-$
(ispell-word
) normally checks the spelling of the word at
point, but it checks the text in the region if the mark is active
(see Checking and Correcting Spelling). Normally, such commands use their default
behavior if the region is empty (i.e., if mark and point are at the
same position). If you want them to operate on the empty region,
change the variable use-empty-active-region
to t
.
As described in Erasing Text, the DEL
(backward-delete-char
) and Delete
(delete-forward-char
) commands also act this way. If the mark
is active, they delete the text in the region. (As an exception, if
you supply a numeric argument n, where n is not one, these
commands delete n characters regardless of whether the mark is
active). If you change the variable delete-active-region
to
nil
, then these commands don’t act differently when the mark is
active. If you change the value to kill
, these commands
kill the region instead of deleting it (see Killing and Moving Text).
Other commands always operate on the region, and have no default
behavior. Such commands usually have the word region
in their
names, like C-w (kill-region
) and C-x C-u
(upcase-region
). If the mark is inactive, they operate on the
inactive region—that is, on the text between point and the
position at which the mark was last set (see The Mark Ring). To
disable this behavior, change the variable
mark-even-if-inactive
to nil
. Then these commands will
instead signal an error if the mark is inactive.
By default, text insertion occurs normally even if the mark is
active—for example, typing a inserts the character ‘a’,
then deactivates the mark. Delete Selection mode, a minor mode,
modifies this behavior: if you enable that mode, then inserting text
while the mark is active causes the text in the region to be deleted
first. However, you can tune this behavior by customizing the
delete-selection-temporary-region
option. Its default value is
nil
, but you can set it to t
, in which case only
temporarily-active regions will be replaced: those which are set by
dragging the mouse (see Setting the Mark) or by shift-selection
(see Shift Selection), as well as by C-u C-x C-x when
Transient Mark Mode is disabled. You can further tune the behavior by
setting delete-selection-temporary-region
to selection
:
then temporary regions by C-u C-x C-x won’t be replaced, only
the ones activated by dragging the mouse or shift-selection. To
toggle Delete Selection mode on or off, type M-x
delete-selection-mode.
Next: The Mark Ring, Previous: Commands to Mark Textual Objects, Up: The Mark and the Region [Contents][Index]