12.2 Transient Mark Mode
On a terminal that supports colors, Emacs has the ability to
highlight the current region. But normally it does not. Why not?
Once you have set the mark in a buffer, there is always a
region in that buffer. This is because every command that sets the
mark also activates it, and nothing ever deactivates it. Highlighting
the region all the time would be a nuisance. So normally Emacs
highlights the region only immediately after you have selected one
with the mouse.
If you want region highlighting, you can use Transient Mark mode.
This is a more rigid mode of operation in which the region always
“lasts” only until you use it; you explicitly must set up a region
for each command that uses one. In Transient Mark mode, most of the
time there is no region; therefore, highlighting the region when it
exists is useful and not annoying. When Transient Mark mode is
enabled, Emacs always highlights the region whenever there is a
To enable Transient Mark mode, type M-x transient-mark-mode.
This command toggles the mode; you can use the same command to turn
the mode off again.
Here are the details of Transient Mark mode:
- To set the mark, type C-<SPC> (
This makes the mark active and thus begins highlighting of the region.
As you move point, you will see the highlighted region grow and
- The mouse commands for specifying the mark also make it active. So do
keyboard commands whose purpose is to specify a region, including
M-@, C-M-@, M-h, C-M-h, C-x C-p, and
- You can tell that the mark is active because the region is highlighted.
- When the mark is active, you can execute commands that operate on the
region, such as killing, indenting, or writing to a file.
- Any change to the buffer, such as inserting or deleting a character,
deactivates the mark. This means any subsequent command that operates
on a region will get an error and refuse to operate. You can make the
region active again by typing C-x C-x.
- If Delete Selection mode is also enabled, some commands delete the
region when used while the mark is active. See Graphical Kill.
- Quitting with C-g deactivates the mark.
- Commands like M-> and C-s, that “leave the mark behind” in
addition to some other primary purpose, do not activate the new mark.
You can activate the new region by executing C-x C-x
- Commands that normally set the mark before moving long distances (like
M-< and C-s) do not alter the mark in Transient Mark mode
when the mark is active.
- Some commands operate on the region if a region is active. For
instance, C-x u in Transient Mark mode operates on the region,
when there is a region. (Outside Transient Mark mode, you must type
C-u C-x u if you want it to operate on the region.)
See Undo. Other commands that act this way are identified in their
The highlighting of the region uses the
region face; you can
customize the appearance of the highlighted region by changing this
face. See Face Customization.
When multiple windows show the same buffer, they can have different
regions, because they can have different values of point (though they
all share one common mark position). Ordinarily, only the selected
window highlights its region (see Windows). However, if the
highlight-nonselected-windows is non-
each window highlights its own region (provided that Transient Mark mode
is enabled and the mark in the window's buffer is active).
If the variable
mark-even-if-inactive is non-
Transient Mark mode, then commands can use the mark and the region
even when it is inactive. Region highlighting appears and disappears
just as it normally does in Transient Mark mode, but the mark doesn't
really go away when the highlighting disappears, so you can still use
Transient Mark mode is also sometimes known as “Zmacs mode”
because the Zmacs editor on the MIT Lisp Machine handled the mark in a