comparison runtime/doc/pattern.txt @ 34:e170173ecb68 current-release

before ack base protocol.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 26 Nov 2008 15:02:10 +0900
parents 76efa0be13f1
children c16898406ff2
comparison
equal deleted inserted replaced
33:7d0d8b831f5a 34:e170173ecb68
1 *pattern.txt* For Vim version 7.1. Last change: 2007 May 11 1 *pattern.txt* For Vim version 7.2. Last change: 2008 Jul 16
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
136 is automatically turned back on when using a search 136 is automatically turned back on when using a search
137 command, or setting the 'hlsearch' option. 137 command, or setting the 'hlsearch' option.
138 This command doesn't work in an autocommand, because 138 This command doesn't work in an autocommand, because
139 the highlighting state is saved and restored when 139 the highlighting state is saved and restored when
140 executing autocommands |autocmd-searchpat|. 140 executing autocommands |autocmd-searchpat|.
141 Same thing for when invoking a user function.
141 142
142 While typing the search pattern the current match will be shown if the 143 While typing the search pattern the current match will be shown if the
143 'incsearch' option is on. Remember that you still have to finish the search 144 'incsearch' option is on. Remember that you still have to finish the search
144 command with <CR> to actually position the cursor at the displayed match. Or 145 command with <CR> to actually position the cursor at the displayed match. Or
145 use <Esc> to abandon the search. 146 use <Esc> to abandon the search.
495 x x a character with no special meaning matches itself 496 x x a character with no special meaning matches itself
496 497
497 |/[]| [] \[] any character specified inside the [] 498 |/[]| [] \[] any character specified inside the []
498 |/\%[]| \%[] \%[] a sequence of optionally matched atoms 499 |/\%[]| \%[] \%[] a sequence of optionally matched atoms
499 500
500 |/\c| \c \c ignore case 501 |/\c| \c \c ignore case, do not use the 'ignorecase' option
501 |/\C| \C \C match case 502 |/\C| \C \C match case, do not use the 'ignorecase' option
502 |/\m| \m \m 'magic' on for the following chars in the pattern 503 |/\m| \m \m 'magic' on for the following chars in the pattern
503 |/\M| \M \M 'magic' off for the following chars in the pattern 504 |/\M| \M \M 'magic' off for the following chars in the pattern
504 |/\v| \v \v the following chars in the pattern are "very magic" 505 |/\v| \v \v the following chars in the pattern are "very magic"
505 |/\V| \V \V the following chars in the pattern are "very nomagic" 506 |/\V| \V \V the following chars in the pattern are "very nomagic"
506 |/\Z| \Z \Z ignore differences in Unicode "combining characters". 507 |/\Z| \Z \Z ignore differences in Unicode "combining characters".
594 match that starts earlier is preferred over a shorter match: "a\{-}b" 595 match that starts earlier is preferred over a shorter match: "a\{-}b"
595 matches "aaab" in "xaaab". 596 matches "aaab" in "xaaab".
596 597
597 Example matches ~ 598 Example matches ~
598 ab\{2,3}c "abbc" or "abbbc" 599 ab\{2,3}c "abbc" or "abbbc"
599 a\{5} "aaaaa". 600 a\{5} "aaaaa"
600 ab\{2,}c "abbc", "abbbc", "abbbbc", etc 601 ab\{2,}c "abbc", "abbbc", "abbbbc", etc.
601 ab\{,3}c "ac", "abc", "abbc" or "abbbc". 602 ab\{,3}c "ac", "abc", "abbc" or "abbbc"
602 a[bc]\{3}d "abbbd", "abbcd", "acbcd", "acccd", etc. 603 a[bc]\{3}d "abbbd", "abbcd", "acbcd", "acccd", etc.
603 a\(bc\)\{1,2}d "abcd" or "abcbcd" 604 a\(bc\)\{1,2}d "abcd" or "abcbcd"
604 a[bc]\{-}[cd] "abc" in "abcd" 605 a[bc]\{-}[cd] "abc" in "abcd"
605 a[bc]*[cd] "abcd" in "abcd" 606 a[bc]*[cd] "abcd" in "abcd"
606 607
679 with what follows, thus an atom that ends in ".*" will work. 680 with what follows, thus an atom that ends in ".*" will work.
680 Warning: This can be slow (because many positions need to be checked 681 Warning: This can be slow (because many positions need to be checked
681 for a match). 682 for a match).
682 Example matches ~ 683 Example matches ~
683 \(foo\)\@<!bar any "bar" that's not in "foobar" 684 \(foo\)\@<!bar any "bar" that's not in "foobar"
684 \(\/\/.*\)\@\<!in "in" which is not after "//" 685 \(\/\/.*\)\@<!in "in" which is not after "//"
685 686
686 */\@>* 687 */\@>*
687 \@> Matches the preceding atom like matching a whole pattern. {not in Vi} 688 \@> Matches the preceding atom like matching a whole pattern. {not in Vi}
688 Like '(?>pattern)" in Perl. 689 Like "(?>pattern)" in Perl.
689 Example matches ~ 690 Example matches ~
690 \(a*\)\@>a nothing (the "a*" takes all the "a"'s, there can't be 691 \(a*\)\@>a nothing (the "a*" takes all the "a"'s, there can't be
691 another one following) 692 another one following)
692 693
693 This matches the preceding atom as if it was a pattern by itself. If 694 This matches the preceding atom as if it was a pattern by itself. If
718 Example matches ~ 719 Example matches ~
719 \_s*\_^foo white space and blank lines and then "foo" at 720 \_s*\_^foo white space and blank lines and then "foo" at
720 start-of-line 721 start-of-line
721 722
722 */$* 723 */$*
723 $ At end of pattern or in front of "\|" or "\)" ("|" or ")" after "\v"): 724 $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
724 matches end-of-line <EOL>; at other positions, matches literal '$'. 725 matches end-of-line <EOL>; at other positions, matches literal '$'.
725 |/zero-width| 726 |/zero-width|
726 727
727 */\$* 728 */\$*
728 \$ Matches literal '$'. Can be used at any position in the pattern. 729 \$ Matches literal '$'. Can be used at any position in the pattern.
868 are halfway through a tab or other character that occupies more than 869 are halfway through a tab or other character that occupies more than
869 one screen character. {not in Vi} 870 one screen character. {not in Vi}
870 WARNING: When inserting or deleting text Vim does not automatically 871 WARNING: When inserting or deleting text Vim does not automatically
871 update highlighted matches. This means Syntax highlighting quickly 872 update highlighted matches. This means Syntax highlighting quickly
872 becomes wrong. 873 becomes wrong.
873 Example, to highlight the all characters after virtual column 72: > 874 Example, to highlight all the characters after virtual column 72: >
874 /\%>72v.* 875 /\%>72v.*
875 < When 'hlsearch' is set and you move the cursor around and make changes 876 < When 'hlsearch' is set and you move the cursor around and make changes
876 this will clearly show when the match is updated or not. 877 this will clearly show when the match is updated or not.
877 To match the text up to column 17: > 878 To match the text up to column 17: >
878 /.*\%17v 879 /.*\%17v
1069 You don't often have to use it, but it is possible. Example: > 1070 You don't often have to use it, but it is possible. Example: >
1070 /\<r\%[[eo]ad]\> 1071 /\<r\%[[eo]ad]\>
1071 < Matches the words "r", "re", "ro", "rea", "roa", "read" and "road". 1072 < Matches the words "r", "re", "ro", "rea", "roa", "read" and "road".
1072 There can be no \(\), \%(\) or \z(\) items inside the [] and \%[] does 1073 There can be no \(\), \%(\) or \z(\) items inside the [] and \%[] does
1073 not nest. 1074 not nest.
1075 To include a "[" use "[[]" and for "]" use []]", e.g.,: >
1076 /index\%[[[]0[]]]
1077 < matches "index" "index[", "index[0" and "index[0]".
1074 {not available when compiled without the +syntax feature} 1078 {not available when compiled without the +syntax feature}
1075 1079
1076 */\%d* */\%x* */\%o* */\%u* */\%U* *E678* 1080 */\%d* */\%x* */\%o* */\%u* */\%U* *E678*
1077 1081
1078 \%d123 Matches the character specified with a decimal number. Must be 1082 \%d123 Matches the character specified with a decimal number. Must be
1116 that typing CTRL-V CTRL-J also inserts a <NL>, thus also searches for a <Nul> 1120 that typing CTRL-V CTRL-J also inserts a <NL>, thus also searches for a <Nul>
1117 in the file. {Vi cannot handle <Nul> characters in the file at all} 1121 in the file. {Vi cannot handle <Nul> characters in the file at all}
1118 1122
1119 *CR-used-for-NL* 1123 *CR-used-for-NL*
1120 When 'fileformat' is "mac", <NL> characters in the file are stored as <CR> 1124 When 'fileformat' is "mac", <NL> characters in the file are stored as <CR>
1121 characters internally. In the display they are shown as "^M". Otherwise this 1125 characters internally. In the text they are shown as "^J". Otherwise this
1122 works similar to the usage of <NL> for a <Nul>. 1126 works similar to the usage of <NL> for a <Nul>.
1123 1127
1124 When working with expression evaluation, a <NL> character in the pattern 1128 When working with expression evaluation, a <NL> character in the pattern
1125 matches a <NL> in the string. The use of "\n" (backslash n) to match a <NL> 1129 matches a <NL> in the string. The use of "\n" (backslash n) to match a <NL>
1126 doesn't work there, it only works to match text in the buffer. 1130 doesn't work there, it only works to match text in the buffer.
1223 when switching to another buffer. 1227 when switching to another buffer.
1224 1228
1225 'ignorecase' does not apply, use |/\c| in the pattern to 1229 'ignorecase' does not apply, use |/\c| in the pattern to
1226 ignore case. Otherwise case is not ignored. 1230 ignore case. Otherwise case is not ignored.
1227 1231
1232 'redrawtime' defines the maximum time searched for pattern
1233 matches.
1234
1228 When matching end-of-line and Vim redraws only part of the 1235 When matching end-of-line and Vim redraws only part of the
1229 display you may get unexpected results. That is because Vim 1236 display you may get unexpected results. That is because Vim
1230 looks for a match in the line where redrawing starts. 1237 looks for a match in the line where redrawing starts.
1231 1238
1232 Also see |matcharg()|and |getmatches()|. The former returns 1239 Also see |matcharg()| and |getmatches()|. The former returns
1233 the highlight group and pattern of a previous |:match| 1240 the highlight group and pattern of a previous |:match|
1234 command. The latter returns a list with highlight groups and 1241 command. The latter returns a list with highlight groups and
1235 patterns defined by both |matchadd()| and |:match|. 1242 patterns defined by both |matchadd()| and |:match|.
1236 1243
1237 Highlighting matches using |:match| are limited to three 1244 Highlighting matches using |:match| are limited to three