Matteo Landi | 59834ba | 2024-11-04 20:46:54 +0100 | [diff] [blame] | 1 | *pi_paren.txt* For Vim version 9.1. Last change: 2024 Nov 04 |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
| 5 | |
| 6 | |
| 7 | Highlighting matching parens *matchparen* |
| 8 | |
| 9 | The functionality mentioned here is a |standard-plugin|. |
| 10 | This plugin is only available if 'compatible' is not set. |
| 11 | |
| 12 | You can avoid loading this plugin by setting the "loaded_matchparen" variable: > |
Matteo Landi | 59834ba | 2024-11-04 20:46:54 +0100 | [diff] [blame] | 13 | |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 14 | :let loaded_matchparen = 1 |
| 15 | |
Bram Moolenaar | fa2e044 | 2007-08-18 16:21:50 +0000 | [diff] [blame] | 16 | The plugin installs CursorMoved, CursorMovedI and WinEnter autocommands to |
| 17 | redefine the match highlighting. |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 18 | |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 19 | *:NoMatchParen* *:DoMatchParen* |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 20 | To disable the plugin after it was loaded use this command: > |
| 21 | |
| 22 | :NoMatchParen |
| 23 | |
| 24 | And to enable it again: > |
| 25 | |
| 26 | :DoMatchParen |
| 27 | |
Bram Moolenaar | fd2ac76 | 2006-03-01 22:09:21 +0000 | [diff] [blame] | 28 | The highlighting used is MatchParen. You can specify different colors with |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 29 | the ":highlight" command. Example: > |
| 30 | |
Bram Moolenaar | fd2ac76 | 2006-03-01 22:09:21 +0000 | [diff] [blame] | 31 | :hi MatchParen ctermbg=blue guibg=lightblue |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 32 | |
Matteo Landi | 59834ba | 2024-11-04 20:46:54 +0100 | [diff] [blame] | 33 | By default the plugin will highlight both the paren under the cursor and the |
| 34 | matching one using the |hl-MatchParen| highlighting group. This may result in |
| 35 | the cursor briefly disappearing from the screen as the MatchParen colors take |
| 36 | over the cursor highlight. To prevent this from happening and have the plugin |
| 37 | only highlight the matching paren and not the one under the cursor |
| 38 | (effectively leaving the cursor style unchanged), you can set the |
| 39 | "matchparen_disable_cursor_hl" variable: > |
| 40 | |
| 41 | :let matchparen_disable_cursor_hl = 1 |
| 42 | |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 43 | The characters to be matched come from the 'matchpairs' option. You can |
| 44 | change the value to highlight different matches. Note that not everything is |
| 45 | possible. For example, you can't highlight single or double quotes, because |
| 46 | the start and end are equal. |
| 47 | |
| 48 | The syntax highlighting attributes are used. When the cursor currently is not |
| 49 | in a string or comment syntax item, then matches inside string and comment |
| 50 | syntax items are ignored. Any syntax items with "string" or "comment" |
| 51 | somewhere in their name are considered string or comment items. |
| 52 | |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 53 | The search is limited to avoid a delay when moving the cursor. The limits |
| 54 | are: |
| 55 | - What is visible in the window. |
| 56 | - 100 lines above or below the cursor to avoid a long delay when there are |
| 57 | closed folds. |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 58 | - 'synmaxcol' times 2 bytes before or after the cursor to avoid a delay |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 59 | in a long line with syntax highlighting. |
Matteo Landi | 59834ba | 2024-11-04 20:46:54 +0100 | [diff] [blame] | 60 | - A timeout of 300 msec (60 msec in Insert mode). This can be changed with |
| 61 | the "g:matchparen_timeout" and "g:matchparen_insert_timeout" variables and |
| 62 | their buffer-local equivalents "b:matchparen_timeout" and |
| 63 | "b:matchparen_insert_timeout". |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 64 | |
| 65 | If you would like the |%| command to work better, the matchit plugin can be |
| 66 | used, see |matchit-install|. This plugin also helps to skip matches in |
| 67 | comments. This is unrelated to the matchparen highlighting, they use a |
| 68 | different mechanism. |
| 69 | |
Bram Moolenaar | 5e3cb7e | 2006-02-27 23:58:35 +0000 | [diff] [blame] | 70 | ============================================================================== |
Bram Moolenaar | 91f84f6 | 2018-07-29 15:07:52 +0200 | [diff] [blame] | 71 | vim:tw=78:ts=8:noet:ft=help:norl: |