Previous: , Up: Parentheses   [Contents][Index]

26.4.3 Matching Parentheses

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, Emacs briefly indicates 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:

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. Conversely, when you insert a closing delimiter over an existing one, no inserting takes places and that position is simply skipped over. These variables control additional features of Electric Pair mode:

To toggle Electric Pair mode, type M-x electric-pair-mode.

Previous: , Up: Parentheses   [Contents][Index]