A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html below:

Matching (GNU Emacs Manual)

Previous: Moving in the Parenthesis Structure, Up: Commands for Editing with Parentheses   [Contents][Index]

28.4.3 Matching Parentheses

Emacs has a number of parenthesis matching features, which make it easy to see how and whether parentheses (or other paired 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 is a minor mode that provides a more powerful kind of automatic matching. Whenever point is before an opening delimiter or after a closing delimiter, the delimiter, its matching delimiter, and optionally the text between them are highlighted. To toggle Show Paren mode globally, type M-x show-paren-mode. To toggle it only in the current buffer, type M-x show-paren-local-mode.

By default, this mode is switched on in all buffers that are meant for editing, but is not enabled in buffers that show data. This is controlled by the show-paren-predicate user option.

To customize the mode, type M-x customize-group RET paren-showing. The customizable options which control the operation of this mode include:

Electric Pair mode is a minor mode that provides a way to easily insert pairs of matching delimiters: parentheses, braces, brackets, quotes, etc. (what counts as matching delimiters depends on the major mode). To toggle Electric Pair mode globally, type M-x electric-pair-mode. To toggle it only in the current buffer, type M-x electric-pair-local-mode.

When this mode is enabled, typing an opening delimiter inserts both that character and, immediately following it, the matching closing delimiter, leaving point between the two. This makes it unnecessary to type a matching closing delimiter in most cases. If you type one nonetheless, Emacs simply inserts that character, unless point is immediately before a closing delimiter of the same type; in that case, point moves to immediately after the closing delimiter and no additional closing delimiter is inserted. Thus, typing the sequence <opening delimiter>, <matching closing delimiter> is a perhaps more convenient alternative to the sequence <opening delimiter>, C-f.

With an active region (see The Mark and the Region), Electric Pair mode operates differently: inserting either an opening or a closing delimiter encloses the characters in the region within the resulting pair of matching delimiters, leaving point after the delimiter you typed (this facilitates continuing to type either before the text following the opening delimiter or after the closing delimiter).

There are several user options for modifying the behavior of Electric Pair mode:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4