Mercurial > vim
comparison runtime/doc/pattern.txt @ 714:0f9f4761ad9c v7.0216
updated for version 7.0216
author | vimboss |
---|---|
date | Mon, 06 Mar 2006 23:29:24 +0000 |
parents | 2af8de31a3a8 |
children | d8f905020502 |
comparison
equal
deleted
inserted
replaced
713:0c381fb7846c | 714:0f9f4761ad9c |
---|---|
1 *pattern.txt* For Vim version 7.0aa. Last change: 2006 Mar 01 | 1 *pattern.txt* For Vim version 7.0aa. Last change: 2006 Mar 06 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
14 3. Magic |/magic| | 14 3. Magic |/magic| |
15 4. Overview of pattern items |pattern-overview| | 15 4. Overview of pattern items |pattern-overview| |
16 5. Multi items |pattern-multi-items| | 16 5. Multi items |pattern-multi-items| |
17 6. Ordinary atoms |pattern-atoms| | 17 6. Ordinary atoms |pattern-atoms| |
18 7. Ignoring case in a pattern |/ignorecase| | 18 7. Ignoring case in a pattern |/ignorecase| |
19 8. Compare with Perl patterns |perl-patterns| | 19 8. Composing characters |patterns-composing| |
20 9. Highlighting matches |match-highlight| | 20 9. Compare with Perl patterns |perl-patterns| |
21 10. Highlighting matches |match-highlight| | |
21 | 22 |
22 ============================================================================== | 23 ============================================================================== |
23 1. Search commands *search-commands* *E486* | 24 1. Search commands *search-commands* *E486* |
24 | 25 |
25 */* | 26 */* |
1102 Foo on off foo Foo FOO | 1103 Foo on off foo Foo FOO |
1103 Foo on on Foo | 1104 Foo on on Foo |
1104 \cfoo - - foo Foo FOO | 1105 \cfoo - - foo Foo FOO |
1105 foo\C - - foo | 1106 foo\C - - foo |
1106 | 1107 |
1107 */\Z* | |
1108 When "\Z" appears anywhere in the pattern, composing characters are ignored. | |
1109 Thus only the base characters need to match, the composing characters may be | |
1110 different and the number of composing characters may differ. Only relevant | |
1111 when 'encoding' is "utf-8". | |
1112 | |
1113 Technical detail: *NL-used-for-Nul* | 1108 Technical detail: *NL-used-for-Nul* |
1114 <Nul> characters in the file are stored as <NL> in memory. In the display | 1109 <Nul> characters in the file are stored as <NL> in memory. In the display |
1115 they are shown as "^@". The translation is done when reading and writing | 1110 they are shown as "^@". The translation is done when reading and writing |
1116 files. To match a <Nul> with a search pattern you can just enter CTRL-@ or | 1111 files. To match a <Nul> with a search pattern you can just enter CTRL-@ or |
1117 "CTRL-V 000". This is probably just what you expect. Internally the | 1112 "CTRL-V 000". This is probably just what you expect. Internally the |
1132 Patterns will also work with multi-byte characters, mostly as you would | 1127 Patterns will also work with multi-byte characters, mostly as you would |
1133 expect. But invalid bytes may cause trouble, a pattern with an invalid byte | 1128 expect. But invalid bytes may cause trouble, a pattern with an invalid byte |
1134 will probably never match. | 1129 will probably never match. |
1135 | 1130 |
1136 ============================================================================== | 1131 ============================================================================== |
1137 8. Compare with Perl patterns *perl-patterns* | 1132 8. Composing characters *patterns-composing* |
1133 | |
1134 */\Z* | |
1135 When "\Z" appears anywhere in the pattern, composing characters are ignored. | |
1136 Thus only the base characters need to match, the composing characters may be | |
1137 different and the number of composing characters may differ. Only relevant | |
1138 when 'encoding' is "utf-8". | |
1139 | |
1140 When a composing character appears at the start of the pattern of after an | |
1141 item that doesn't include the composing character, a match is found at any | |
1142 character that includes this composing character. | |
1143 | |
1144 When using a dot and a composing character, this works the same as the | |
1145 composing character by itself, except that it doesn't matter what comes before | |
1146 this. | |
1147 | |
1148 The order of composing characters matters, even though changing the order | |
1149 doen't change what a character looks like. This may change in the future. | |
1150 | |
1151 ============================================================================== | |
1152 9. Compare with Perl patterns *perl-patterns* | |
1138 | 1153 |
1139 Vim's regexes are most similar to Perl's, in terms of what you can do. The | 1154 Vim's regexes are most similar to Perl's, in terms of what you can do. The |
1140 difference between them is mostly just notation; here's a summary of where | 1155 difference between them is mostly just notation; here's a summary of where |
1141 they differ: | 1156 they differ: |
1142 | 1157 |
1143 Capability in Vimspeak in Perlspeak ~ | 1158 Capability in Vimspeak in Perlspeak ~ |
1144 ---------------------------------------------------------------- | 1159 ---------------------------------------------------------------- |
1145 force case insensitivity \c (?i) | 1160 force case insensitivity \c (?i) |
1146 force case sensitivity \C (?-i) | 1161 force case sensitivity \C (?-i) |
1147 backref-less grouping \%(atom) (?:atom) | 1162 backref-less grouping \%(atom\) (?:atom) |
1148 conservative quantifiers \{-n,m} *?, +?, ??, {}? | 1163 conservative quantifiers \{-n,m} *?, +?, ??, {}? |
1149 0-width match atom\@= (?=atom) | 1164 0-width match atom\@= (?=atom) |
1150 0-width non-match atom\@! (?!atom) | 1165 0-width non-match atom\@! (?!atom) |
1151 0-width preceding match atom\@<= (?<=atom) | 1166 0-width preceding match atom\@<= (?<=atom) |
1152 0-width preceding non-match atom\@<! (?<!atom) | 1167 0-width preceding non-match atom\@<! (?<!atom) |
1175 (very useful for avoiding backslashitis) | 1190 (very useful for avoiding backslashitis) |
1176 - sequence of optionally matching atoms: \%[atoms] | 1191 - sequence of optionally matching atoms: \%[atoms] |
1177 - \& (which is to \| what "and" is to "or"; it forces several branches | 1192 - \& (which is to \| what "and" is to "or"; it forces several branches |
1178 to match at one spot) | 1193 to match at one spot) |
1179 - matching lines/columns by number: \%5l \%5c \%5v | 1194 - matching lines/columns by number: \%5l \%5c \%5v |
1180 - limiting the "return value" of a regex: \zs \ze | 1195 - setting the start and end of the match: \zs \ze |
1181 | 1196 |
1182 ============================================================================== | 1197 ============================================================================== |
1183 9. Highlighting matches *match-highlight* | 1198 10. Highlighting matches *match-highlight* |
1184 | 1199 |
1185 *:mat* *:match* | 1200 *:mat* *:match* |
1186 :mat[ch] {group} /{pattern}/ | 1201 :mat[ch] {group} /{pattern}/ |
1187 Define a pattern to highlight in the current window. It will | 1202 Define a pattern to highlight in the current window. It will |
1188 be highlighted with {group}. Example: > | 1203 be highlighted with {group}. Example: > |