1
- *pattern.txt* For Vim version 8.2. Last change: 2020 Dec 06
1
+ *pattern.txt* For Vim version 8.2. Last change: 2021 Jan 08
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -394,15 +394,19 @@ the pattern will not match. This is only useful when debugging Vim.
394
394
==============================================================================
395
395
3. Magic */magic*
396
396
397
- Some characters in the pattern are taken literally. They match with the same
398
- character in the text. When preceded with a backslash however, these
399
- characters get a special meaning.
397
+ Some characters in the pattern, such as letters, are taken literally. They
398
+ match exactly the same character in the text. When preceded with a backslash
399
+ however, these characters may get a special meaning. For example, "a" matches
400
+ the letter "a", while "\a" matches any alphabetic character.
400
401
401
402
Other characters have a special meaning without a backslash. They need to be
402
- preceded with a backslash to match literally.
403
+ preceded with a backslash to match literally. For example "." matches any
404
+ character while "\." matches a dot.
403
405
404
406
If a character is taken literally or not depends on the 'magic' option and the
405
- items mentioned next.
407
+ items in the pattern mentioned next. The 'magic' option should always be set,
408
+ but it can be switched off for Vi compatibility. We mention the effect of
409
+ 'nomagic' here for completeness, but we recommend against using that.
406
410
*/\m* */\M*
407
411
Use of "\m" makes the pattern after it be interpreted as if 'magic' is set,
408
412
ignoring the actual value of the 'magic' option.
@@ -411,30 +415,28 @@ Use of "\M" makes the pattern after it be interpreted as if 'nomagic' is used.
411
415
Use of "\v" means that after it, all ASCII characters except '0'-'9', 'a'-'z',
412
416
'A'-'Z' and '_' have special meaning: "very magic"
413
417
414
- Use of "\V" means that after it, only a backslash and terminating character
415
- (usually / or ?) have special meaning: "very nomagic"
418
+ Use of "\V" means that after it, only a backslash and the terminating
419
+ character (usually / or ?) have special meaning: "very nomagic"
416
420
417
421
Examples:
418
422
after: \v \m \M \V matches ~
419
423
'magic' 'nomagic'
420
- $ $ $ \$ matches end-of-line
421
- . . \. \. matches any character
424
+ a a a a literal 'a'
425
+ \a \a \a \a any alphabetic character
426
+ . . \. \. any character
427
+ \. \. . . literal dot
428
+ $ $ $ \$ end-of-line
422
429
* * \* \* any number of the previous atom
423
430
~ ~ \~ \~ latest substitute string
424
- () \(\) \(\) \(\) grouping into an atom
425
- | \ | \| \ | separating alternatives
426
- \a \a \a \a alphabetic character
431
+ () \(\) \(\) \(\) group as an atom
432
+ | \ | \| \ | nothing: separates alternatives
427
433
\\ \\ \\ \\ literal backslash
428
- \. \. . . literal dot
429
- \{ { { { literal '{'
430
- a a a a literal 'a'
434
+ \{ { { { literal curly brace
431
435
432
436
{only Vim supports \m, \M, \v and \V}
433
437
434
- It is recommended to always keep the 'magic' option at the default setting,
435
- which is 'magic' . This avoids portability problems. To make a pattern immune
436
- to the 'magic' option being set or not, put "\m" or "\M" at the start of the
437
- pattern.
438
+ If you want to you can make a pattern immune to the 'magic' option being set
439
+ or not by putting "\m" or "\M" at the start of the pattern.
438
440
439
441
==============================================================================
440
442
4. Overview of pattern items *pattern-overview*
@@ -1177,7 +1179,7 @@ x A single character, with no special meaning, matches itself
1177
1179
\b <BS>
1178
1180
\n line break, see above | /[\n] |
1179
1181
\d123 decimal number of character
1180
- \o40 octal number of character up to 0377
1182
+ \o40 octal number of character up to 0o377
1181
1183
\x20 hexadecimal number of character up to 0xff
1182
1184
\u20AC hex. number of multibyte character up to 0xffff
1183
1185
\U1234 hex. number of multibyte character up to 0xffffffff
@@ -1215,7 +1217,8 @@ x A single character, with no special meaning, matches itself
1215
1217
\%d123 Matches the character specified with a decimal number. Must be
1216
1218
followed by a non-digit.
1217
1219
\%o40 Matches the character specified with an octal number up to 0377.
1218
- Numbers below 040 must be followed by a non-octal digit or a non-digit.
1220
+ Numbers below 0o40 must be followed by a non-octal digit or a
1221
+ non-digit.
1219
1222
\%x2a Matches the character specified with up to two hexadecimal characters.
1220
1223
\%u20AC Matches the character specified with up to four hexadecimal
1221
1224
characters.
0 commit comments