M-x all-things-emacs

Newbie Tip: transient-mark-mode

February 20th, 2007 by Ryan McGeary · 152 Comments

Setting a mark (C-SPC) is probably the most frequent command I use besides basic navigation. The mark not only acts as a saved jump-to point, but it also sets the region. A region is what other editors might call a selection. By default, emacs does not highlight the active region, so it requires a bit of imagination to visualize it. To change that behavior, add this to your .emacs.

(setq transient-mark-mode t)

This turns the Transient Mark minor mode on. In Transient Mark mode, when the mark is active, the region is highlighted.


Note: Some commands change their behavior when transient mark mode is on and the mark is active. Personally, I like the changed behavior, but invoke C-h d transient for more information.

Tags: newbie · quick · tips

152 responses so far ↓

  • 1 alephnull // Feb 20, 2007 at 7:49 am

    I used to track multi-tty and I found that tmm breaks the menubar sometimes. I have not encountered this problem ever since I started using unicode-2 with the GTK UI.

  • 2 Yann Hodique // Feb 20, 2007 at 2:33 pm

    It is worth noting that in the next major version of GNU Emacs, pressing C-SPC two times in a row enables transient-mark-mode temporarily.

    This way, one is able to take advantage of the modified behavior of some commands (comment-dwim for example) without enabling the “region selection” globally.

    Personally I like to use the mark not only for defining a region, but also simply for marking a place I’ll come back later to, with C-u C-SPC

  • 3 Rob Christie // Feb 20, 2007 at 3:25 pm

    Also, if you happen to use pc-selection-mode it turns on transient-mark-mode automatically.

  • 4 Ryan McGeary // Feb 20, 2007 at 4:15 pm

    Yann is referring to Emacs 22, and C-SPC C-SPC is a good tip for those that don’t want to permanently enable transient-mark-mode.

  • 5 sean // Feb 25, 2007 at 5:43 am

    Yann — C-u C-spc has to be one of the most underrated Emacs commands. I happen to find that TMM + C-spc + C-g to cancel region highlighting is more efficient for me, but it’s a matter of taste.

  • 6 Jesper Juhl // Jan 10, 2010 at 10:19 pm

    Just wanted to say, that if you are like me and find transient-mark-mode annoying and your distribution has made emacs enable it by default (as mine does), then it’s easy to disable by just setting

    (setq transient-mark-mode nil)

    in your ~/.emacs file…

  • 7 retrot // Feb 18, 2010 at 12:33 pm

    Thank you jesper juhl!!!

  • 8 http://nikeause.exteen.com/20130709/goretex-protection-for-timberland-boots-canada // Jul 13, 2013 at 12:04 pm

    Newbie Tip: transient-mark-mode | M-x all-things-emacs