1 *pattern.txt* For Vim version 7.2. Last change: 2008 Sep 05
4 VIM REFERENCE MANUAL by Bram Moolenaar
7 Patterns and search commands *pattern-searches*
9 The very basics can be found in section |03.9| of the user manual. A few more
10 explanations are in chapter 27 |usr_27.txt|.
12 1. Search commands |search-commands|
13 2. The definition of a pattern |search-pattern|
15 4. Overview of pattern items |pattern-overview|
16 5. Multi items |pattern-multi-items|
17 6. Ordinary atoms |pattern-atoms|
18 7. Ignoring case in a pattern |/ignorecase|
19 8. Composing characters |patterns-composing|
20 9. Compare with Perl patterns |perl-patterns|
21 10. Highlighting matches |match-highlight|
23 ==============================================================================
24 1. Search commands *search-commands* *E486*
27 /{pattern}[/]<CR> Search forward for the [count]'th occurrence of
28 {pattern} |exclusive|.
30 /{pattern}/{offset}<CR> Search forward for the [count]'th occurrence of
31 {pattern} and go |{offset}| lines up or down.
35 /<CR> Search forward for the [count]'th occurrence of the
36 latest used pattern |last-pattern| with latest used
39 //{offset}<CR> Search forward for the [count]'th occurrence of the
40 latest used pattern |last-pattern| with new
41 |{offset}|. If {offset} is empty no offset is used.
44 ?{pattern}[?]<CR> Search backward for the [count]'th previous
45 occurrence of {pattern} |exclusive|.
47 ?{pattern}?{offset}<CR> Search backward for the [count]'th previous
48 occurrence of {pattern} and go |{offset}| lines up or
52 ?<CR> Search backward for the [count]'th occurrence of the
53 latest used pattern |last-pattern| with latest used
56 ??{offset}<CR> Search backward for the [count]'th occurrence of the
57 latest used pattern |last-pattern| with new
58 |{offset}|. If {offset} is empty no offset is used.
61 n Repeat the latest "/" or "?" [count] times.
62 |last-pattern| {Vi: no count}
65 N Repeat the latest "/" or "?" [count] times in
66 opposite direction. |last-pattern| {Vi: no count}
69 * Search forward for the [count]'th occurrence of the
70 word nearest to the cursor. The word used for the
71 search is the first of:
72 1. the keyword under the cursor |'iskeyword'|
73 2. the first keyword after the cursor, in the
75 3. the non-blank word under the cursor
76 4. the first non-blank word after the cursor,
78 Only whole keywords are searched for, like with the
79 command "/\<keyword\>". |exclusive| {not in Vi}
80 'ignorecase' is used, 'smartcase' is not.
83 # Same as "*", but search backward. The pound sign
84 (character 163) also works. If the "#" key works as
85 backspace, try using "stty erase <BS>" before starting
86 Vim (<BS> is CTRL-H or a real backspace). {not in Vi}
89 g* Like "*", but don't put "\<" and "\>" around the word.
90 This makes the search also find matches that are not a
91 whole word. {not in Vi}
94 g# Like "#", but don't put "\<" and "\>" around the word.
95 This makes the search also find matches that are not a
96 whole word. {not in Vi}
99 gd Goto local Declaration. When the cursor is on a local
100 variable, this command will jump to its declaration.
101 First Vim searches for the start of the current
102 function, just like "[[". If it is not found the
103 search stops in line 1. If it is found, Vim goes back
104 until a blank line is found. From this position Vim
105 searches for the keyword under the cursor, like with
106 "*", but lines that look like a comment are ignored
107 (see 'comments' option).
108 Note that this is not guaranteed to work, Vim does not
109 really check the syntax, it only searches for a match
110 with the keyword. If included files also need to be
111 searched use the commands listed in |include-search|.
112 After this command |n| searches forward for the next
113 match (not backward).
117 gD Goto global Declaration. When the cursor is on a
118 global variable that is defined in the file, this
119 command will jump to its declaration. This works just
120 like "gd", except that the search for the keyword
121 always starts in line 1. {not in Vi}
124 1gd Like "gd", but ignore matches inside a {} block that
125 ends before the cursor position. {not in Vi}
128 1gD Like "gD", but ignore matches inside a {} block that
129 ends before the cursor position. {not in Vi}
132 CTRL-C Interrupt current (search) command. Use CTRL-Break on
133 MS-DOS |dos-CTRL-Break|.
134 In Normal mode, any pending command is aborted.
137 :noh[lsearch] Stop the highlighting for the 'hlsearch' option. It
138 is automatically turned back on when using a search
139 command, or setting the 'hlsearch' option.
140 This command doesn't work in an autocommand, because
141 the highlighting state is saved and restored when
142 executing autocommands |autocmd-searchpat|.
143 Same thing for when invoking a user function.
145 While typing the search pattern the current match will be shown if the
146 'incsearch' option is on. Remember that you still have to finish the search
147 command with <CR> to actually position the cursor at the displayed match. Or
148 use <Esc> to abandon the search.
150 All matches for the last used search pattern will be highlighted if you set
151 the 'hlsearch' option. This can be suspended with the |:nohlsearch| command.
153 *search-offset* *{offset}*
154 These commands search for the specified pattern. With "/" and "?" an
155 additional offset may be given. There are two types of offsets: line offsets
156 and character offsets. {the character offsets are not in Vi}
158 The offset gives the cursor position relative to the found match:
159 [num] [num] lines downwards, in column 1
160 +[num] [num] lines downwards, in column 1
161 -[num] [num] lines upwards, in column 1
162 e[+num] [num] characters to the right of the end of the match
163 e[-num] [num] characters to the left of the end of the match
164 s[+num] [num] characters to the right of the start of the match
165 s[-num] [num] characters to the left of the start of the match
166 b[+num] [num] identical to s[+num] above (mnemonic: begin)
167 b[-num] [num] identical to s[-num] above (mnemonic: begin)
168 ;{pattern} perform another search, see |//;|
170 If a '-' or '+' is given but [num] is omitted, a count of one will be used.
171 When including an offset with 'e', the search becomes inclusive (the
172 character the cursor lands on is included in operations).
176 pattern cursor position ~
177 /test/+1 one line below "test", in column 1
178 /test/e on the last t of "test"
179 /test/s+2 on the 's' of "test"
180 /test/b-3 three characters before "test"
182 If one of these commands is used after an operator, the characters between
183 the cursor position before and after the search is affected. However, if a
184 line offset is given, the whole lines between the two cursor positions are
187 An example of how to search for matches with a pattern and change the match
190 c//e change until end of match
191 bar<Esc> type replacement
192 //<CR> go to start of next match
193 c//e change until end of match
194 beep<Esc> type another replacement
198 A very special offset is ';' followed by another search command. For example: >
203 The first one first finds the next occurrence of "test 1", and then the first
204 occurrence of "test" after that.
206 This is like executing two search commands after each other, except that:
207 - It can be used as a single motion command after an operator.
208 - The direction for a following "n" or "N" command comes from the first
210 - When an error occurs the cursor is not moved at all.
213 The last used pattern and offset are remembered. They can be used to repeat
214 the search, possibly in another direction or with another count. Note that
215 two patterns are remembered: One for 'normal' search commands and one for the
216 substitute command ":s". Each time an empty pattern is given, the previously
217 used pattern is used.
219 The 'magic' option sticks with the last used pattern. If you change 'magic',
220 this will not change how the last used pattern will be interpreted.
221 The 'ignorecase' option does not do this. When 'ignorecase' is changed, it
222 will result in the pattern to match other text.
224 All matches for the last used search pattern will be highlighted if you set
225 the 'hlsearch' option.
227 To clear the last used search pattern: >
229 This will not set the pattern to an empty string, because that would match
230 everywhere. The pattern is really cleared, like when starting Vim.
232 The search usually skips matches that don't move the cursor. Whether the next
233 match is found at the next character or after the skipped match depends on the
234 'c' flag in 'cpoptions'. See |cpo-c|.
235 with 'c' flag: "/..." advances 1 to 3 characters
236 without 'c' flag: "/..." advances 1 character
237 The unpredictability with the 'c' flag is caused by starting the search in the
238 first column, skipping matches until one is found past the cursor position.
240 When searching backwards, searching starts at the start of the line, using the
241 'c' flag in 'cpoptions' as described above. Then the last match before the
242 cursor position is used.
244 In Vi the ":tag" command sets the last search pattern when the tag is searched
245 for. In Vim this is not done, the previous search pattern is still remembered,
246 unless the 't' flag is present in 'cpoptions'. The search pattern is always
247 put in the search history.
249 If the 'wrapscan' option is on (which is the default), searches wrap around
250 the end of the buffer. If 'wrapscan' is not set, the backward search stops
251 at the beginning and the forward search stops at the end of the buffer. If
252 'wrapscan' is set and the pattern was not found the error message "pattern
253 not found" is given, and the cursor will not be moved. If 'wrapscan' is not
254 set the message becomes "search hit BOTTOM without match" when searching
255 forward, or "search hit TOP without match" when searching backward. If
256 wrapscan is set and the search wraps around the end of the file the message
257 "search hit TOP, continuing at BOTTOM" or "search hit BOTTOM, continuing at
258 TOP" is given when searching backwards or forwards respectively. This can be
259 switched off by setting the 's' flag in the 'shortmess' option. The highlight
260 method 'w' is used for this message (default: standout).
263 You can limit the search command "/" to a certain range of lines by including
264 \%>l items. For example, to match the word "limit" below line 199 and above
269 Another way is to use the ":substitute" command with the 'c' flag. Example: >
271 This command will search from the cursor position until line 300 for
272 "Pattern". At the match, you will be asked to type a character. Type 'q' to
273 stop at this match, type 'n' to find the next match.
275 The "*", "#", "g*" and "g#" commands look for a word near the cursor in this
276 order, the first one that is found is used:
277 - The keyword currently under the cursor.
278 - The first keyword to the right of the cursor, in the same line.
279 - The WORD currently under the cursor.
280 - The first WORD to the right of the cursor, in the same line.
281 The keyword may only contain letters and characters in 'iskeyword'.
282 The WORD may contain any non-blanks (<Tab>s and/or <Space>s).
283 Note that if you type with ten fingers, the characters are easy to remember:
284 the "#" is under your left hand middle finger (search to the left and up) and
285 the "*" is under your right hand middle finger (search to the right and down).
286 (this depends on your keyboard layout though).
288 ==============================================================================
289 2. The definition of a pattern *search-pattern* *pattern* *[pattern]*
290 *regular-expression* *regexp* *Pattern*
293 For starters, read chapter 27 of the user manual |usr_27.txt|.
295 */bar* */\bar* */pattern*
296 1. A pattern is one or more branches, separated by "\|". It matches anything
297 that matches one of the branches. Example: "foo\|beep" matches "foo" and
298 matches "beep". If more than one branch matches, the first one is used.
302 or branch \| branch \| branch
306 2. A branch is one or more concats, separated by "\&". It matches the last
307 concat, but only if all the preceding concats also match at the same
309 "foobeep\&..." matches "foo" in "foobeep".
310 ".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob"
314 or concat \& concat \& concat
318 3. A concat is one or more pieces, concatenated. It matches a match for the
319 first piece, followed by a match for the second piece, etc. Example:
320 "f[0-9]b", first matches "f", then a digit and then "b".
328 4. A piece is an atom, possibly followed by a multi, an indication of how many
329 times the atom can be matched. Example: "a*" matches any sequence of "a"
330 characters: "", "a", "aa", etc. See |/multi|.
336 5. An atom can be one of a long list of items. Many atoms match one character
337 in the text. It is often an ordinary character or a character class.
338 Braces can be used to make a pattern into an atom. The "\z(\)" construct
339 is only for syntax highlighting.
341 atom ::= ordinary-atom |/ordinary-atom|
342 or \( pattern \) |/\(|
343 or \%( pattern \) |/\%(|
344 or \z( pattern \) |/\z(|
347 ==============================================================================
350 Some characters in the pattern are taken literally. They match with the same
351 character in the text. When preceded with a backslash however, these
352 characters get a special meaning.
354 Other characters have a special meaning without a backslash. They need to be
355 preceded with a backslash to match literally.
357 If a character is taken literally or not depends on the 'magic' option and the
358 items mentioned next.
360 Use of "\m" makes the pattern after it be interpreted as if 'magic' is set,
361 ignoring the actual value of the 'magic' option.
362 Use of "\M" makes the pattern after it be interpreted as if 'nomagic' is used.
364 Use of "\v" means that in the pattern after it all ASCII characters except
365 '0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning. "very magic"
367 Use of "\V" means that in the pattern after it only the backslash has a
368 special meaning. "very nomagic"
371 after: \v \m \M \V matches ~
373 $ $ $ \$ matches end-of-line
374 . . \. \. matches any character
375 * * \* \* any number of the previous atom
376 () \(\) \(\) \(\) grouping into an atom
377 | \| \| \| separating alternatives
378 \a \a \a \a alphabetic character
379 \\ \\ \\ \\ literal backslash
380 \. \. . . literal dot
384 {only Vim supports \m, \M, \v and \V}
386 It is recommended to always keep the 'magic' option at the default setting,
387 which is 'magic'. This avoids portability problems. To make a pattern immune
388 to the 'magic' option being set or not, put "\m" or "\M" at the start of the
391 ==============================================================================
392 4. Overview of pattern items *pattern-overview*
394 Overview of multi items. */multi* *E61* *E62*
395 More explanation and examples below, follow the links. *E64*
398 'magic' 'nomagic' matches of the preceding atom ~
399 |/star| * \* 0 or more as many as possible
400 |/\+| \+ \+ 1 or more as many as possible (*)
401 |/\=| \= \= 0 or 1 as many as possible (*)
402 |/\?| \? \? 0 or 1 as many as possible (*)
404 |/\{| \{n,m} \{n,m} n to m as many as possible (*)
405 \{n} \{n} n exactly (*)
406 \{n,} \{n,} at least n as many as possible (*)
407 \{,m} \{,m} 0 to m as many as possible (*)
408 \{} \{} 0 or more as many as possible (same as *) (*)
410 |/\{-| \{-n,m} \{-n,m} n to m as few as possible (*)
411 \{-n} \{-n} n exactly (*)
412 \{-n,} \{-n,} at least n as few as possible (*)
413 \{-,m} \{-,m} 0 to m as few as possible (*)
414 \{-} \{-} 0 or more as few as possible (*)
417 |/\@>| \@> \@> 1, like matching a whole pattern (*)
418 |/\@=| \@= \@= nothing, requires a match |/zero-width| (*)
419 |/\@!| \@! \@! nothing, requires NO match |/zero-width| (*)
420 |/\@<=| \@<= \@<= nothing, requires a match behind |/zero-width| (*)
421 |/\@<!| \@<! \@<! nothing, requires NO match behind |/zero-width| (*)
426 Overview of ordinary atoms. */ordinary-atom*
427 More explanation and examples below, follow the links.
430 magic nomagic matches ~
431 |/^| ^ ^ start-of-line (at start of pattern) |/zero-width|
432 |/\^| \^ \^ literal '^'
433 |/\_^| \_^ \_^ start-of-line (used anywhere) |/zero-width|
434 |/$| $ $ end-of-line (at end of pattern) |/zero-width|
435 |/\$| \$ \$ literal '$'
436 |/\_$| \_$ \_$ end-of-line (used anywhere) |/zero-width|
437 |/.| . \. any single character (not an end-of-line)
438 |/\_.| \_. \_. any single character or end-of-line
439 |/\<| \< \< beginning of a word |/zero-width|
440 |/\>| \> \> end of a word |/zero-width|
441 |/\zs| \zs \zs anything, sets start of match
442 |/\ze| \ze \ze anything, sets end of match
443 |/\%^| \%^ \%^ beginning of file |/zero-width| *E71*
444 |/\%$| \%$ \%$ end of file |/zero-width|
445 |/\%V| \%V \%V inside Visual area |/zero-width|
446 |/\%#| \%# \%# cursor position |/zero-width|
447 |/\%'m| \%'m \%'m mark m position |/zero-width|
448 |/\%l| \%23l \%23l in line 23 |/zero-width|
449 |/\%c| \%23c \%23c in column 23 |/zero-width|
450 |/\%v| \%23v \%23v in virtual column 23 |/zero-width|
452 Character classes {not in Vi}: */character-classes*
453 |/\i| \i \i identifier character (see 'isident' option)
454 |/\I| \I \I like "\i", but excluding digits
455 |/\k| \k \k keyword character (see 'iskeyword' option)
456 |/\K| \K \K like "\k", but excluding digits
457 |/\f| \f \f file name character (see 'isfname' option)
458 |/\F| \F \F like "\f", but excluding digits
459 |/\p| \p \p printable character (see 'isprint' option)
460 |/\P| \P \P like "\p", but excluding digits
461 |/\s| \s \s whitespace character: <Space> and <Tab>
462 |/\S| \S \S non-whitespace character; opposite of \s
463 |/\d| \d \d digit: [0-9]
464 |/\D| \D \D non-digit: [^0-9]
465 |/\x| \x \x hex digit: [0-9A-Fa-f]
466 |/\X| \X \X non-hex digit: [^0-9A-Fa-f]
467 |/\o| \o \o octal digit: [0-7]
468 |/\O| \O \O non-octal digit: [^0-7]
469 |/\w| \w \w word character: [0-9A-Za-z_]
470 |/\W| \W \W non-word character: [^0-9A-Za-z_]
471 |/\h| \h \h head of word character: [A-Za-z_]
472 |/\H| \H \H non-head of word character: [^A-Za-z_]
473 |/\a| \a \a alphabetic character: [A-Za-z]
474 |/\A| \A \A non-alphabetic character: [^A-Za-z]
475 |/\l| \l \l lowercase character: [a-z]
476 |/\L| \L \L non-lowercase character: [^a-z]
477 |/\u| \u \u uppercase character: [A-Z]
478 |/\U| \U \U non-uppercase character [^A-Z]
479 |/\_| \_x \_x where x is any of the characters above: character
480 class with end-of-line included
481 (end of character classes)
487 |/\n| \n \n end-of-line
488 |/~| ~ \~ last given substitute string
489 |/\1| \1 \1 same string as matched by first \(\) {not in Vi}
490 |/\2| \2 \2 Like "\1", but uses second \(\)
492 |/\9| \9 \9 Like "\1", but uses ninth \(\)
494 |/\z1| \z1 \z1 only for syntax highlighting, see |:syn-ext-match|
496 |/\z1| \z9 \z9 only for syntax highlighting, see |:syn-ext-match|
498 x x a character with no special meaning matches itself
500 |/[]| [] \[] any character specified inside the []
501 |/\%[]| \%[] \%[] a sequence of optionally matched atoms
503 |/\c| \c \c ignore case, do not use the 'ignorecase' option
504 |/\C| \C \C match case, do not use the 'ignorecase' option
505 |/\m| \m \m 'magic' on for the following chars in the pattern
506 |/\M| \M \M 'magic' off for the following chars in the pattern
507 |/\v| \v \v the following chars in the pattern are "very magic"
508 |/\V| \V \V the following chars in the pattern are "very nomagic"
509 |/\Z| \Z \Z ignore differences in Unicode "combining characters".
510 Useful when searching voweled Hebrew or Arabic text.
512 |/\%d| \%d \%d match specified decimal character (eg \%d123)
513 |/\%x| \%x \%x match specified hex character (eg \%x2a)
514 |/\%o| \%o \%o match specified octal character (eg \%o040)
515 |/\%u| \%u \%u match specified multibyte character (eg \%u20ac)
516 |/\%U| \%U \%U match specified large multibyte character (eg
522 \<[a-zA-Z_][a-zA-Z0-9_]*
523 An identifier (e.g., in a C program).
525 \(\.$\|\. \) A period followed by <EOL> or a space.
527 [.!?][])"']*\($\|[ ]\) A search pattern that finds the end of a sentence,
528 with almost the same definition as the ")" command.
530 cat\Z Both "cat" and "càt" ("a" followed by 0x0300)
531 Does not match "cà t" (character 0x00e0), even
532 though it may look the same.
535 ==============================================================================
536 5. Multi items *pattern-multi-items*
538 An atom can be followed by an indication of how many times the atom can be
539 matched and in what way. This is called a multi. See |/multi| for an
542 */star* */\star* *E56*
543 * (use \* when 'magic' is not set)
544 Matches 0 or more of the preceding atom, as many as possible.
545 Example 'nomagic' matches ~
546 a* a\* "", "a", "aa", "aaa", etc.
547 .* \.\* anything, also an empty string, no end-of-line
548 \_.* \_.\* everything up to the end of the buffer
549 \_.*END \_.\*END everything up to and including the last "END"
552 Exception: When "*" is used at the start of the pattern or just after
553 "^" it matches the star character.
555 Be aware that repeating "\_." can match a lot of text and take a long
556 time. For example, "\_.*END" matches all text from the current
557 position to the last occurrence of "END" in the file. Since the "*"
558 will match as many as possible, this first skips over all lines until
559 the end of the file and then tries matching "END", backing up one
563 \+ Matches 1 or more of the preceding atom, as many as possible. {not in
566 ^.\+$ any non-empty line
567 \s\+ white space of at least one character
570 \= Matches 0 or 1 of the preceding atom, as many as possible. {not in Vi}
575 \? Just like \=. Cannot be used when searching backwards with the "?"
578 */\{* *E58* *E60* *E554*
579 \{n,m} Matches n to m of the preceding atom, as many as possible
580 \{n} Matches n of the preceding atom
581 \{n,} Matches at least n of the preceding atom, as many as possible
582 \{,m} Matches 0 to m of the preceding atom, as many as possible
583 \{} Matches 0 or more of the preceding atom, as many as possible (like *)
585 \{-n,m} matches n to m of the preceding atom, as few as possible
586 \{-n} matches n of the preceding atom
587 \{-n,} matches at least n of the preceding atom, as few as possible
588 \{-,m} matches 0 to m of the preceding atom, as few as possible
589 \{-} matches 0 or more of the preceding atom, as few as possible
590 {Vi does not have any of these}
592 n and m are positive decimal numbers or zero
594 If a "-" appears immediately after the "{", then a shortest match
595 first algorithm is used (see example below). In particular, "\{-}" is
596 the same as "*" but uses the shortest match first algorithm. BUT: A
597 match that starts earlier is preferred over a shorter match: "a\{-}b"
598 matches "aaab" in "xaaab".
601 ab\{2,3}c "abbc" or "abbbc"
603 ab\{2,}c "abbc", "abbbc", "abbbbc", etc.
604 ab\{,3}c "ac", "abc", "abbc" or "abbbc"
605 a[bc]\{3}d "abbbd", "abbcd", "acbcd", "acccd", etc.
606 a\(bc\)\{1,2}d "abcd" or "abcbcd"
607 a[bc]\{-}[cd] "abc" in "abcd"
608 a[bc]*[cd] "abcd" in "abcd"
610 The } may optionally be preceded with a backslash: \{n,m\}.
613 \@= Matches the preceding atom with zero width. {not in Vi}
614 Like "(?=pattern)" in Perl.
616 foo\(bar\)\@= "foo" in "foobar"
617 foo\(bar\)\@=foo nothing
619 When using "\@=" (or "^", "$", "\<", "\>") no characters are included
620 in the match. These items are only used to check if a match can be
621 made. This can be tricky, because a match with following items will
622 be done in the same position. The last example above will not match
623 "foobarfoo", because it tries match "foo" in the same position where
626 Note that using "\&" works the same as using "\@=": "foo\&.." is the
627 same as "\(foo\)\@=..". But using "\&" is easier, you don't need the
632 \@! Matches with zero width if the preceding atom does NOT match at the
633 current position. |/zero-width| {not in Vi}
634 Like '(?!pattern)" in Perl.
636 foo\(bar\)\@! any "foo" not followed by "bar"
637 a.\{-}p\@! "a", "ap", "app", etc. not followed by a "p"
638 if \(\(then\)\@!.\)*$ "if " not followed by "then"
640 Using "\@!" is tricky, because there are many places where a pattern
641 does not match. "a.*p\@!" will match from an "a" to the end of the
642 line, because ".*" can match all characters in the line and the "p"
643 doesn't match at the end of the line. "a.\{-}p\@!" will match any
644 "a", "ap", "aap", etc. that isn't followed by a "p", because the "."
645 can match a "p" and "p\@!" doesn't match after that.
647 You can't use "\@!" to look for a non-match before the matching
648 position: "\(foo\)\@!bar" will match "bar" in "foobar", because at the
649 position where "bar" matches, "foo" does not match. To avoid matching
650 "foobar" you could use "\(foo\)\@!...bar", but that doesn't match a
651 bar at the start of a line. Use "\(foo\)\@<!bar".
654 \@<= Matches with zero width if the preceding atom matches just before what
655 follows. |/zero-width| {not in Vi}
656 Like '(?<=pattern)" in Perl, but Vim allows non-fixed-width patterns.
658 \(an\_s\+\)\@<=file "file" after "an" and white space or an
660 For speed it's often much better to avoid this multi. Try using "\zs"
661 instead |/\zs|. To match the same as the above example:
664 "\@<=" and "\@<!" check for matches just before what follows.
665 Theoretically these matches could start anywhere before this position.
666 But to limit the time needed, only the line where what follows matches
667 is searched, and one line before that (if there is one). This should
668 be sufficient to match most things and not be too slow.
669 The part of the pattern after "\@<=" and "\@<!" are checked for a
670 match first, thus things like "\1" don't work to reference \(\) inside
671 the preceding atom. It does work the other way around:
673 \1\@<=,\([a-z]\+\) ",abc" in "abc,abc"
676 \@<! Matches with zero width if the preceding atom does NOT match just
677 before what follows. Thus this matches if there is no position in the
678 current or previous line where the atom matches such that it ends just
679 before what follows. |/zero-width| {not in Vi}
680 Like '(?<!pattern)" in Perl, but Vim allows non-fixed-width patterns.
681 The match with the preceding atom is made to end just before the match
682 with what follows, thus an atom that ends in ".*" will work.
683 Warning: This can be slow (because many positions need to be checked
686 \(foo\)\@<!bar any "bar" that's not in "foobar"
687 \(\/\/.*\)\@<!in "in" which is not after "//"
690 \@> Matches the preceding atom like matching a whole pattern. {not in Vi}
691 Like "(?>pattern)" in Perl.
693 \(a*\)\@>a nothing (the "a*" takes all the "a"'s, there can't be
694 another one following)
696 This matches the preceding atom as if it was a pattern by itself. If
697 it doesn't match, there is no retry with shorter sub-matches or
698 anything. Observe this difference: "a*b" and "a*ab" both match
699 "aaab", but in the second case the "a*" matches only the first two
700 "a"s. "\(a*\)\@>ab" will not match "aaab", because the "a*" matches
701 the "aaa" (as many "a"s as possible), thus the "ab" can't match.
704 ==============================================================================
705 6. Ordinary atoms *pattern-atoms*
707 An ordinary atom can be:
710 ^ At beginning of pattern or after "\|", "\(", "\%(" or "\n": matches
711 start-of-line; at other positions, matches literal '^'. |/zero-width|
713 ^beep( the start of the C function "beep" (probably).
716 \^ Matches literal '^'. Can be used at any position in the pattern.
719 \_^ Matches start-of-line. |/zero-width| Can be used at any position in
722 \_s*\_^foo white space and blank lines and then "foo" at
726 $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
727 matches end-of-line <EOL>; at other positions, matches literal '$'.
731 \$ Matches literal '$'. Can be used at any position in the pattern.
734 \_$ Matches end-of-line. |/zero-width| Can be used at any position in the
735 pattern. Note that "a\_$b" never matches, since "b" cannot match an
736 end-of-line. Use "a\nb" instead |/\n|.
738 foo\_$\_s* "foo" at end-of-line and following white space and
741 . (with 'nomagic': \.) */.* */\.*
742 Matches any single character, but not an end-of-line.
745 \_. Matches any single character or end-of-line.
746 Careful: "\_.*" matches all text to the end of the buffer!
749 \< Matches the beginning of a word: The next char is the first char of a
750 word. The 'iskeyword' option specifies what is a word character.
754 \> Matches the end of a word: The previous char is the last char of a
755 word. The 'iskeyword' option specifies what is a word character.
759 \zs Matches at any position, and sets the start of the match there: The
760 next char is the first char of the whole match. |/zero-width|
763 < matches an "if" at the start of a line, ignoring white space.
764 Can be used multiple times, the last one encountered in a matching
765 branch is used. Example: >
767 < Finds the third occurrence of "Fab".
768 {not in Vi} {not available when compiled without the +syntax feature}
770 \ze Matches at any position, and sets the end of the match there: The
771 previous char is the last char of the whole match. |/zero-width|
772 Can be used multiple times, the last one encountered in a matching
774 Example: "end\ze\(if\|for\)" matches the "end" in "endif" and
776 {not in Vi} {not available when compiled without the +syntax feature}
778 */\%^* *start-of-file*
779 \%^ Matches start of the file. When matching with a string, matches the
780 start of the string. {not in Vi}
781 For example, to find the first "VIM" in a file: >
785 \%$ Matches end of the file. When matching with a string, matches the
786 end of the string. {not in Vi}
787 Note that this does NOT find the last "VIM" in a file: >
789 < It will find the next VIM, because the part after it will always
790 match. This one will find the last "VIM" in the file: >
791 /VIM\ze\(\(VIM\)\@!\_.\)*\%$
792 < This uses |/\@!| to ascertain that "VIM" does NOT match in any
793 position after the first "VIM".
794 Searching from the end of the file backwards is easier!
797 \%V Match inside the Visual area. When Visual mode has already been
798 stopped match in the area that |gv| would reselect.
799 This is a |/zero-width| match. To make sure the whole pattern is
800 inside the Visual area put it at the start and end of the pattern,
803 < Only works for the current buffer.
805 */\%#* *cursor-position*
806 \%# Matches with the cursor position. Only works when matching in a
807 buffer displayed in a window. {not in Vi}
808 WARNING: When the cursor is moved after the pattern was used, the
809 result becomes invalid. Vim doesn't automatically update the matches.
810 This is especially relevant for syntax highlighting and 'hlsearch'.
811 In other words: When the cursor moves the display isn't updated for
812 this change. An update is done for lines which are changed (the whole
813 line is updated) or when using the |CTRL-L| command (the whole screen
814 is updated). Example, to highlight the word under the cursor: >
816 < When 'hlsearch' is set and you move the cursor around and make changes
817 this will clearly show when the match is updated or not.
819 */\%'m* */\%<'m* */\%>'m*
820 \%'m Matches with the position of mark m.
821 \%<'m Matches before the position of mark m.
822 \%>'m Matches after the position of mark m.
823 Example, to highlight the text from mark 's to 'e: >
825 < Note that two dots are required to include mark 'e in the match. That
826 is because "\%<'e" matches at the character before the 'e mark, and
827 since it's a |/zero-width| match it doesn't include that character.
829 WARNING: When the mark is moved after the pattern was used, the result
830 becomes invalid. Vim doesn't automatically update the matches.
831 Similar to moving the cursor for "\%#" |/\%#|.
833 */\%l* */\%>l* */\%<l*
834 \%23l Matches in a specific line.
835 \%<23l Matches above a specific line (lower line number).
836 \%>23l Matches below a specific line (higher line number).
837 These three can be used to match specific lines in a buffer. The "23"
838 can be any line number. The first line is 1. {not in Vi}
839 WARNING: When inserting or deleting lines Vim does not automatically
840 update the matches. This means Syntax highlighting quickly becomes
842 Example, to highlight the line where the cursor currently is: >
843 :exe '/\%' . line(".") . 'l.*'
844 < When 'hlsearch' is set and you move the cursor around and make changes
845 this will clearly show when the match is updated or not.
847 */\%c* */\%>c* */\%<c*
848 \%23c Matches in a specific column.
849 \%<23c Matches before a specific column.
850 \%>23c Matches after a specific column.
851 These three can be used to match specific columns in a buffer or
852 string. The "23" can be any column number. The first column is 1.
853 Actually, the column is the byte number (thus it's not exactly right
854 for multi-byte characters). {not in Vi}
855 WARNING: When inserting or deleting text Vim does not automatically
856 update the matches. This means Syntax highlighting quickly becomes
858 Example, to highlight the column where the cursor currently is: >
859 :exe '/\%' . col(".") . 'c'
860 < When 'hlsearch' is set and you move the cursor around and make changes
861 this will clearly show when the match is updated or not.
862 Example for matching a single byte in column 44: >
864 < Note that "\%<46c" matches in column 45 when the "." matches a byte in
866 */\%v* */\%>v* */\%<v*
867 \%23v Matches in a specific virtual column.
868 \%<23v Matches before a specific virtual column.
869 \%>23v Matches after a specific virtual column.
870 These three can be used to match specific virtual columns in a buffer
871 or string. When not matching with a buffer in a window, the option
872 values of the current window are used (e.g., 'tabstop').
873 The "23" can be any column number. The first column is 1.
874 Note that some virtual column positions will never match, because they
875 are halfway through a tab or other character that occupies more than
876 one screen character. {not in Vi}
877 WARNING: When inserting or deleting text Vim does not automatically
878 update highlighted matches. This means Syntax highlighting quickly
880 Example, to highlight all the characters after virtual column 72: >
882 < When 'hlsearch' is set and you move the cursor around and make changes
883 this will clearly show when the match is updated or not.
884 To match the text up to column 17: >
886 < Column 17 is not included, because that's where the "\%17v" matches,
887 and since this is a |/zero-width| match, column 17 isn't included in
888 the match. This does the same: >
892 Character classes: {not in Vi}
893 \i identifier character (see 'isident' option) */\i*
894 \I like "\i", but excluding digits */\I*
895 \k keyword character (see 'iskeyword' option) */\k*
896 \K like "\k", but excluding digits */\K*
897 \f file name character (see 'isfname' option) */\f*
898 \F like "\f", but excluding digits */\F*
899 \p printable character (see 'isprint' option) */\p*
900 \P like "\p", but excluding digits */\P*
902 NOTE: the above also work for multi-byte characters. The ones below only
903 match ASCII characters, as indicated by the range.
905 *whitespace* *white-space*
906 \s whitespace character: <Space> and <Tab> */\s*
907 \S non-whitespace character; opposite of \s */\S*
908 \d digit: [0-9] */\d*
909 \D non-digit: [^0-9] */\D*
910 \x hex digit: [0-9A-Fa-f] */\x*
911 \X non-hex digit: [^0-9A-Fa-f] */\X*
912 \o octal digit: [0-7] */\o*
913 \O non-octal digit: [^0-7] */\O*
914 \w word character: [0-9A-Za-z_] */\w*
915 \W non-word character: [^0-9A-Za-z_] */\W*
916 \h head of word character: [A-Za-z_] */\h*
917 \H non-head of word character: [^A-Za-z_] */\H*
918 \a alphabetic character: [A-Za-z] */\a*
919 \A non-alphabetic character: [^A-Za-z] */\A*
920 \l lowercase character: [a-z] */\l*
921 \L non-lowercase character: [^a-z] */\L*
922 \u uppercase character: [A-Z] */\u*
923 \U non-uppercase character [^A-Z] */\U*
925 NOTE: Using the atom is faster than the [] form.
927 NOTE: 'ignorecase', "\c" and "\C" are not used by character classes.
929 */\_* *E63* */\_i* */\_I* */\_k* */\_K* */\_f* */\_F*
930 */\_p* */\_P* */\_s* */\_S* */\_d* */\_D* */\_x* */\_X*
931 */\_o* */\_O* */\_w* */\_W* */\_h* */\_H* */\_a* */\_A*
932 */\_l* */\_L* */\_u* */\_U*
933 \_x Where "x" is any of the characters above: The character class with
935 (end of character classes)
937 \e matches <Esc> */\e*
938 \t matches <Tab> */\t*
939 \r matches <CR> */\r*
940 \b matches <BS> */\b*
941 \n matches an end-of-line */\n*
942 When matching in a string instead of buffer text a literal newline
943 character is matched.
945 ~ matches the last given substitute string */~* */\~*
947 \(\) A pattern enclosed by escaped parentheses. */\(* */\(\)* */\)*
948 E.g., "\(^a\)" matches 'a' at the start of a line. *E51* *E54* *E55*
950 \1 Matches the same string that was matched by */\1* *E65*
951 the first sub-expression in \( and \). {not in Vi}
952 Example: "\([a-z]\).\1" matches "ata", "ehe", "tot", etc.
953 \2 Like "\1", but uses second sub-expression, */\2*
955 \9 Like "\1", but uses ninth sub-expression. */\9*
956 Note: The numbering of groups is done based on which "\(" comes first
957 in the pattern (going left to right), NOT based on what is matched
960 \%(\) A pattern enclosed by escaped parentheses. */\%(\)* */\%(* *E53*
961 Just like \(\), but without counting it as a sub-expression. This
962 allows using more groups and it's a little bit faster.
965 x A single character, with no special meaning, matches itself
968 \x A backslash followed by a single character, with no special meaning,
969 is reserved for future expansions
971 [] (with 'nomagic': \[]) */[]* */\[]* */\_[]* */collection*
973 A collection. This is a sequence of characters enclosed in brackets.
974 It matches any single character in the collection.
976 [xyz] any 'x', 'y' or 'z'
977 [a-zA-Z]$ any alphabetic character at the end of a line
980 With "\_" prepended the collection also includes the end-of-line.
981 The same can be done by including "\n" in the collection. The
982 end-of-line is also matched when the collection starts with "^"! Thus
983 "\_[^ab]" matches the end-of-line and any character but "a" and "b".
984 This makes it Vi compatible: Without the "\_" or "\n" the collection
985 does not match an end-of-line.
987 When the ']' is not there Vim will not give an error message but
988 assume no collection is used. Useful to search for '['. However, you
989 do get E769 for internal searching.
991 If the sequence begins with "^", it matches any single character NOT
992 in the collection: "[^xyz]" matches anything but 'x', 'y' and 'z'.
993 - If two characters in the sequence are separated by '-', this is
994 shorthand for the full list of ASCII characters between them. E.g.,
995 "[0-9]" matches any decimal digit.
996 - A character class expression is evaluated to the set of characters
997 belonging to that character class. The following character classes
1000 *[:alnum:]* [:alnum:] letters and digits
1001 *[:alpha:]* [:alpha:] letters
1002 *[:blank:]* [:blank:] space and tab characters
1003 *[:cntrl:]* [:cntrl:] control characters
1004 *[:digit:]* [:digit:] decimal digits
1005 *[:graph:]* [:graph:] printable characters excluding space
1006 *[:lower:]* [:lower:] lowercase letters (all letters when
1007 'ignorecase' is used)
1008 *[:print:]* [:print:] printable characters including space
1009 *[:punct:]* [:punct:] punctuation characters
1010 *[:space:]* [:space:] whitespace characters
1011 *[:upper:]* [:upper:] uppercase letters (all letters when
1012 'ignorecase' is used)
1013 *[:xdigit:]* [:xdigit:] hexadecimal digits
1014 *[:return:]* [:return:] the <CR> character
1015 *[:tab:]* [:tab:] the <Tab> character
1016 *[:escape:]* [:escape:] the <Esc> character
1017 *[:backspace:]* [:backspace:] the <BS> character
1018 The brackets in character class expressions are additional to the
1019 brackets delimiting a collection. For example, the following is a
1020 plausible pattern for a UNIX filename: "[-./[:alnum:]_~]\+" That is,
1021 a list of at least one character, each of which is either '-', '.',
1022 '/', alphabetic, numeric, '_' or '~'.
1023 These items only work for 8-bit characters.
1025 - An equivalence class. This means that characters are matched that
1026 have almost the same meaning, e.g., when ignoring accents. The form
1029 Currently this is only implemented for latin1. Also works for the
1030 latin1 characters in utf-8 and latin9.
1032 - A collation element. This currently simply accepts a single
1033 character in the form:
1036 - To include a literal ']', '^', '-' or '\' in the collection, put a
1037 backslash before it: "[xyz\]]", "[\^xyz]", "[xy\-z]" and "[xyz\\]".
1038 (Note: POSIX does not support the use of a backslash this way). For
1039 ']' you can also make it the first character (following a possible
1040 "^"): "[]xyz]" or "[^]xyz]" {not in Vi}.
1041 For '-' you can also make it the first or last character: "[-xyz]",
1042 "[^-xyz]" or "[xyz-]". For '\' you can also let it be followed by
1043 any character that's not in "^]-\bertn". "[\xyz]" matches '\', 'x',
1044 'y' and 'z'. It's better to use "\\" though, future expansions may
1045 use other characters after '\'.
1046 - The following translations are accepted when the 'l' flag is not
1047 included in 'cpoptions' {not in Vi}:
1050 \r <CR> (NOT end-of-line!)
1052 \n line break, see above |/[\n]|
1053 \d123 decimal number of character
1054 \o40 octal number of character up to 0377
1055 \x20 hexadecimal number of character up to 0xff
1056 \u20AC hex. number of multibyte character up to 0xffff
1057 \U1234 hex. number of multibyte character up to 0xffffffff
1058 NOTE: The other backslash codes mentioned above do not work inside
1060 - Matching with a collection can be slow, because each character in
1061 the text has to be compared with each character in the collection.
1062 Use one of the other atoms above when possible. Example: "\d" is
1063 much faster than "[0-9]" and matches the same characters.
1065 */\%[]* *E69* *E70* *E369*
1066 \%[] A sequence of optionally matched atoms. This always matches.
1067 It matches as much of the list of atoms it contains as possible. Thus
1068 it stops at the first atom that doesn't match. For example: >
1070 < matches "r", "re", "rea" or "read". The longest that matches is used.
1071 To match the Ex command "function", where "fu" is required and
1072 "nction" is optional, this would work: >
1074 < The end-of-word atom "\>" is used to avoid matching "fu" in "full".
1075 It gets more complicated when the atoms are not ordinary characters.
1076 You don't often have to use it, but it is possible. Example: >
1078 < Matches the words "r", "re", "ro", "rea", "roa", "read" and "road".
1079 There can be no \(\), \%(\) or \z(\) items inside the [] and \%[] does
1081 To include a "[" use "[[]" and for "]" use []]", e.g.,: >
1083 < matches "index" "index[", "index[0" and "index[0]".
1084 {not available when compiled without the +syntax feature}
1086 */\%d* */\%x* */\%o* */\%u* */\%U* *E678*
1088 \%d123 Matches the character specified with a decimal number. Must be
1089 followed by a non-digit.
1090 \%o40 Matches the character specified with an octal number up to 0377.
1091 Numbers below 040 must be followed by a non-octal digit or a non-digit.
1092 \%x2a Matches the character specified with up to two hexadecimal characters.
1093 \%u20AC Matches the character specified with up to four hexadecimal
1095 \%U1234abcd Matches the character specified with up to eight hexadecimal
1098 ==============================================================================
1099 7. Ignoring case in a pattern */ignorecase*
1101 If the 'ignorecase' option is on, the case of normal letters is ignored.
1102 'smartcase' can be set to ignore case when the pattern contains lowercase
1105 When "\c" appears anywhere in the pattern, the whole pattern is handled like
1106 'ignorecase' is on. The actual value of 'ignorecase' and 'smartcase' is
1107 ignored. "\C" does the opposite: Force matching case for the whole pattern.
1108 {only Vim supports \c and \C}
1109 Note that 'ignorecase', "\c" and "\C" are not used for the character classes.
1112 pattern 'ignorecase' 'smartcase' matches ~
1114 foo on - foo Foo FOO
1115 Foo on off foo Foo FOO
1117 \cfoo - - foo Foo FOO
1120 Technical detail: *NL-used-for-Nul*
1121 <Nul> characters in the file are stored as <NL> in memory. In the display
1122 they are shown as "^@". The translation is done when reading and writing
1123 files. To match a <Nul> with a search pattern you can just enter CTRL-@ or
1124 "CTRL-V 000". This is probably just what you expect. Internally the
1125 character is replaced with a <NL> in the search pattern. What is unusual is
1126 that typing CTRL-V CTRL-J also inserts a <NL>, thus also searches for a <Nul>
1127 in the file. {Vi cannot handle <Nul> characters in the file at all}
1130 When 'fileformat' is "mac", <NL> characters in the file are stored as <CR>
1131 characters internally. In the text they are shown as "^J". Otherwise this
1132 works similar to the usage of <NL> for a <Nul>.
1134 When working with expression evaluation, a <NL> character in the pattern
1135 matches a <NL> in the string. The use of "\n" (backslash n) to match a <NL>
1136 doesn't work there, it only works to match text in the buffer.
1138 *pattern-multi-byte*
1139 Patterns will also work with multi-byte characters, mostly as you would
1140 expect. But invalid bytes may cause trouble, a pattern with an invalid byte
1141 will probably never match.
1143 ==============================================================================
1144 8. Composing characters *patterns-composing*
1147 When "\Z" appears anywhere in the pattern, composing characters are ignored.
1148 Thus only the base characters need to match, the composing characters may be
1149 different and the number of composing characters may differ. Only relevant
1150 when 'encoding' is "utf-8".
1152 When a composing character appears at the start of the pattern of after an
1153 item that doesn't include the composing character, a match is found at any
1154 character that includes this composing character.
1156 When using a dot and a composing character, this works the same as the
1157 composing character by itself, except that it doesn't matter what comes before
1160 The order of composing characters matters, even though changing the order
1161 doesn't change what a character looks like. This may change in the future.
1163 ==============================================================================
1164 9. Compare with Perl patterns *perl-patterns*
1166 Vim's regexes are most similar to Perl's, in terms of what you can do. The
1167 difference between them is mostly just notation; here's a summary of where
1170 Capability in Vimspeak in Perlspeak ~
1171 ----------------------------------------------------------------
1172 force case insensitivity \c (?i)
1173 force case sensitivity \C (?-i)
1174 backref-less grouping \%(atom\) (?:atom)
1175 conservative quantifiers \{-n,m} *?, +?, ??, {}?
1176 0-width match atom\@= (?=atom)
1177 0-width non-match atom\@! (?!atom)
1178 0-width preceding match atom\@<= (?<=atom)
1179 0-width preceding non-match atom\@<! (?<!atom)
1180 match without retry atom\@> (?>atom)
1182 Vim and Perl handle newline characters inside a string a bit differently:
1184 In Perl, ^ and $ only match at the very beginning and end of the text,
1185 by default, but you can set the 'm' flag, which lets them match at
1186 embedded newlines as well. You can also set the 's' flag, which causes
1187 a . to match newlines as well. (Both these flags can be changed inside
1188 a pattern using the same syntax used for the i flag above, BTW.)
1190 On the other hand, Vim's ^ and $ always match at embedded newlines, and
1191 you get two separate atoms, \%^ and \%$, which only match at the very
1192 start and end of the text, respectively. Vim solves the second problem
1193 by giving you the \_ "modifier": put it in front of a . or a character
1194 class, and they will match newlines as well.
1196 Finally, these constructs are unique to Perl:
1197 - execution of arbitrary code in the regex: (?{perl code})
1198 - conditional expressions: (?(condition)true-expr|false-expr)
1200 ...and these are unique to Vim:
1201 - changing the magic-ness of a pattern: \v \V \m \M
1202 (very useful for avoiding backslashitis)
1203 - sequence of optionally matching atoms: \%[atoms]
1204 - \& (which is to \| what "and" is to "or"; it forces several branches
1205 to match at one spot)
1206 - matching lines/columns by number: \%5l \%5c \%5v
1207 - setting the start and end of the match: \zs \ze
1209 ==============================================================================
1210 10. Highlighting matches *match-highlight*
1213 :mat[ch] {group} /{pattern}/
1214 Define a pattern to highlight in the current window. It will
1215 be highlighted with {group}. Example: >
1216 :highlight MyGroup ctermbg=green guibg=green
1217 :match MyGroup /TODO/
1218 < Instead of // any character can be used to mark the start and
1219 end of the {pattern}. Watch out for using special characters,
1220 such as '"' and '|'.
1222 {group} must exist at the moment this command is executed.
1224 The {group} highlighting still applies when a character is
1225 to be highlighted for 'hlsearch', as the highlighting for
1226 matches is given higher priority than that of 'hlsearch'.
1227 Syntax highlighting (see 'syntax') is also overruled by
1230 Note that highlighting the last used search pattern with
1231 'hlsearch' is used in all windows, while the pattern defined
1232 with ":match" only exists in the current window. It is kept
1233 when switching to another buffer.
1235 'ignorecase' does not apply, use |/\c| in the pattern to
1236 ignore case. Otherwise case is not ignored.
1238 'redrawtime' defines the maximum time searched for pattern
1241 When matching end-of-line and Vim redraws only part of the
1242 display you may get unexpected results. That is because Vim
1243 looks for a match in the line where redrawing starts.
1245 Also see |matcharg()| and |getmatches()|. The former returns
1246 the highlight group and pattern of a previous |:match|
1247 command. The latter returns a list with highlight groups and
1248 patterns defined by both |matchadd()| and |:match|.
1250 Highlighting matches using |:match| are limited to three
1251 matches (aside from |:match|, |:2match| and |:3match|are
1252 available). |matchadd()| does not have this limitation and in
1253 addition makes it possible to prioritize matches.
1255 Another example, which highlights all characters in virtual
1256 column 72 and more: >
1257 :highlight rightMargin term=bold ctermfg=blue guifg=blue
1258 :match rightMargin /.\%>72v/
1259 < To highlight all character that are in virtual column 7: >
1260 :highlight col8 ctermbg=grey guibg=grey
1261 :match col8 /\%<8v.\%>7v/
1262 < Note the use of two items to also match a character that
1263 occupies more than one virtual column, such as a TAB.
1267 Clear a previously defined match pattern.
1270 :2mat[ch] {group} /{pattern}/ *:2match*
1273 :3mat[ch] {group} /{pattern}/ *:3match*
1276 Just like |:match| above, but set a separate match. Thus
1277 there can be three matches active at the same time. The match
1278 with the lowest number has priority if several match at the
1280 The ":3match" command is used by the |matchparen| plugin. You
1281 are suggested to use ":match" for manual matching and
1282 ":2match" for another plugin.
1285 vim:tw=78:ts=8:ft=help:norl: