Previous: Moving by Parens, Up: Parentheses [Contents][Index]
Emacs has a number of parenthesis matching features, which make it easy to see how and whether parentheses (or other delimiters) match up.
Whenever you type a self-inserting character that is a closing delimiter, the cursor moves momentarily to the location of the matching opening delimiter, provided that is on the screen. If it is not on the screen, Emacs displays some of the text near it in the echo area. Either way, you can tell which grouping you are closing off. If the opening delimiter and closing delimiter are mismatched—such as in ‘[x)’—a warning message is displayed in the echo area.
Three variables control the display of matching parentheses:
blink-matching-paren
turns the feature on or off: nil
disables it, but the default is t
to enable it.
blink-matching-delay
says how many seconds to leave the cursor
on the matching opening delimiter, before bringing it back to the real
location of point. This may be an integer or floating-point number;
the default is 1.
blink-matching-paren-distance
specifies how many characters
back to search to find the matching opening delimiter. If the match
is not found in that distance, Emacs stops scanning and nothing is
displayed. The default is 102400.
Show Paren mode, a global minor mode, provides a more powerful kind of automatic matching. Whenever point is before an opening delimiter or after a closing delimiter, both that delimiter and its opposite delimiter are highlighted. To toggle Show Paren mode, type M-x show-paren-mode.
Electric Pair mode, a global minor mode, provides a way to easily insert matching delimiters. Whenever you insert an opening delimiter, the matching closing delimiter is automatically inserted as well, leaving point between the two. To toggle Electric Pair mode, type M-x electric-pair-mode.
Previous: Moving by Parens, Up: Parentheses [Contents][Index]