summaryrefslogtreecommitdiffstats
path: root/runtime/doc/pattern.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-05 18:13:34 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-05 18:13:34 +0200
commit25c9c680ec4dfbb51f4ef21c3460a48d3c67ffc8 (patch)
tree0b70444195e194bf5c99df419361bc2052373c02 /runtime/doc/pattern.txt
parent9a061cb78ccbf78ec9ae454d37a49edccb4e94fc (diff)
patch 8.1.1280: remarks about functionality not in Vi clutters the helpv8.1.1280
Problem: Remarks about functionality not in Vi clutters the help. Solution: Move all info about what is new in Vim or already existed in Vi to vi_diff.txt. Remove {not in Vi} remarks. (closes #4268) Add "noet" to the help files modeline. Also include many other help file improvements.
Diffstat (limited to 'runtime/doc/pattern.txt')
-rw-r--r--runtime/doc/pattern.txt119
1 files changed, 52 insertions, 67 deletions
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index fc4502d0cf..8babf0b236 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1,4 +1,4 @@
-*pattern.txt* For Vim version 8.1. Last change: 2019 Feb 21
+*pattern.txt* For Vim version 8.1. Last change: 2019 May 05
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -78,24 +78,24 @@ N Repeat the latest "/" or "?" [count] times in
4. the first non-blank word after the cursor,
in the current line
Only whole keywords are searched for, like with the
- command "/\<keyword\>". |exclusive| {not in Vi}
+ command "/\<keyword\>". |exclusive|
'ignorecase' is used, 'smartcase' is not.
*#*
# Same as "*", but search backward. The pound sign
(character 163) also works. If the "#" key works as
backspace, try using "stty erase <BS>" before starting
- Vim (<BS> is CTRL-H or a real backspace). {not in Vi}
+ Vim (<BS> is CTRL-H or a real backspace).
*gstar*
g* Like "*", but don't put "\<" and "\>" around the word.
This makes the search also find matches that are not a
- whole word. {not in Vi}
+ whole word.
*g#*
g# Like "#", but don't put "\<" and "\>" around the word.
This makes the search also find matches that are not a
- whole word. {not in Vi}
+ whole word.
*gd*
gd Goto local Declaration. When the cursor is on a local
@@ -113,22 +113,21 @@ gd Goto local Declaration. When the cursor is on a local
searched use the commands listed in |include-search|.
After this command |n| searches forward for the next
match (not backward).
- {not in Vi}
*gD*
gD Goto global Declaration. When the cursor is on a
global variable that is defined in the file, this
command will jump to its declaration. This works just
like "gd", except that the search for the keyword
- always starts in line 1. {not in Vi}
+ always starts in line 1.
*1gd*
1gd Like "gd", but ignore matches inside a {} block that
- ends before the cursor position. {not in Vi}
+ ends before the cursor position.
*1gD*
1gD Like "gD", but ignore matches inside a {} block that
- ends before the cursor position. {not in Vi}
+ ends before the cursor position.
*CTRL-C*
CTRL-C Interrupt current (search) command. Use CTRL-Break on
@@ -171,7 +170,7 @@ error message |:s_flags|.
*search-offset* *{offset}*
These commands search for the specified pattern. With "/" and "?" an
additional offset may be given. There are two types of offsets: line offsets
-and character offsets. {the character offsets are not in Vi}
+and character offsets.
The offset gives the cursor position relative to the found match:
[num] [num] lines downwards, in column 1
@@ -312,14 +311,6 @@ triggered. In most cases this should be fine, but if a pattern is in use when
it's used again it fails. Usually this means there is something wrong with
the pattern.
- *E956*
-In very rare cases a regular expression is used recursively. This can happen
-when executing a pattern takes a long time and when checking for messages on
-channels a callback is invoked that also uses a pattern or an autocommand is
-triggered. In most cases this should be fine, but if a pattern is in use when
-it's used again it fails. Usually this means there is something wrong with
-the pattern.
-
==============================================================================
2. The definition of a pattern *search-pattern* *pattern* *[pattern]*
*regular-expression* *regexp* *Pattern*
@@ -455,30 +446,28 @@ More explanation and examples below, follow the links. *E64* *E871*
multi ~
'magic' 'nomagic' matches of the preceding atom ~
|/star| * \* 0 or more as many as possible
-|/\+| \+ \+ 1 or more as many as possible (*)
-|/\=| \= \= 0 or 1 as many as possible (*)
-|/\?| \? \? 0 or 1 as many as possible (*)
-
-|/\{| \{n,m} \{n,m} n to m as many as possible (*)
- \{n} \{n} n exactly (*)
- \{n,} \{n,} at least n as many as possible (*)
- \{,m} \{,m} 0 to m as many as possible (*)
- \{} \{} 0 or more as many as possible (same as *) (*)
-
-|/\{-| \{-n,m} \{-n,m} n to m as few as possible (*)
- \{-n} \{-n} n exactly (*)
- \{-n,} \{-n,} at least n as few as possible (*)
- \{-,m} \{-,m} 0 to m as few as possible (*)
- \{-} \{-} 0 or more as few as possible (*)
+|/\+| \+ \+ 1 or more as many as possible
+|/\=| \= \= 0 or 1 as many as possible
+|/\?| \? \? 0 or 1 as many as possible
+
+|/\{| \{n,m} \{n,m} n to m as many as possible
+ \{n} \{n} n exactly
+ \{n,} \{n,} at least n as many as possible
+ \{,m} \{,m} 0 to m as many as possible
+ \{} \{} 0 or more as many as possible (same as *)
+
+|/\{-| \{-n,m} \{-n,m} n to m as few as possible
+ \{-n} \{-n} n exactly
+ \{-n,} \{-n,} at least n as few as possible
+ \{-,m} \{-,m} 0 to m as few as possible
+ \{-} \{-} 0 or more as few as possible
*E59*
-|/\@>| \@> \@> 1, like matching a whole pattern (*)
-|/\@=| \@= \@= nothing, requires a match |/zero-width| (*)
-|/\@!| \@! \@! nothing, requires NO match |/zero-width| (*)
-|/\@<=| \@<= \@<= nothing, requires a match behind |/zero-width| (*)
-|/\@<!| \@<! \@<! nothing, requires NO match behind |/zero-width| (*)
-
-(*) {not in Vi}
+|/\@>| \@> \@> 1, like matching a whole pattern
+|/\@=| \@= \@= nothing, requires a match |/zero-width|
+|/\@!| \@! \@! nothing, requires NO match |/zero-width|
+|/\@<=| \@<= \@<= nothing, requires a match behind |/zero-width|
+|/\@<!| \@<! \@<! nothing, requires NO match behind |/zero-width|
Overview of ordinary atoms. */ordinary-atom*
@@ -507,7 +496,7 @@ More explanation and examples below, follow the links.
|/\%c| \%23c \%23c in column 23 |/zero-width|
|/\%v| \%23v \%23v in virtual column 23 |/zero-width|
-Character classes {not in Vi}: */character-classes*
+Character classes: */character-classes*
magic nomagic matches ~
|/\i| \i \i identifier character (see 'isident' option)
|/\I| \I \I like "\i", but excluding digits
@@ -546,7 +535,7 @@ Character classes {not in Vi}: */character-classes*
|/\b| \b \b <BS>
|/\n| \n \n end-of-line
|/~| ~ \~ last given substitute string
-|/\1| \1 \1 same string as matched by first \(\) {not in Vi}
+|/\1| \1 \1 same string as matched by first \(\)
|/\2| \2 \2 Like "\1", but uses second \(\)
...
|/\9| \9 \9 Like "\1", but uses ninth \(\)
@@ -624,20 +613,19 @@ overview.
character at a time.
*/\+*
-\+ Matches 1 or more of the preceding atom, as many as possible. {not in
- Vi}
+\+ Matches 1 or more of the preceding atom, as many as possible.
Example matches ~
^.\+$ any non-empty line
\s\+ white space of at least one character
*/\=*
-\= Matches 0 or 1 of the preceding atom, as many as possible. {not in Vi}
+\= Matches 0 or 1 of the preceding atom, as many as possible.
Example matches ~
foo\= "fo" and "foo"
*/\?*
\? Just like \=. Cannot be used when searching backwards with the "?"
- command. {not in Vi}
+ command.
*/\{* *E60* *E554* *E870*
\{n,m} Matches n to m of the preceding atom, as many as possible
@@ -651,7 +639,6 @@ overview.
\{-n,} matches at least n of the preceding atom, as few as possible
\{-,m} matches 0 to m of the preceding atom, as few as possible
\{-} matches 0 or more of the preceding atom, as few as possible
- {Vi does not have any of these}
n and m are positive decimal numbers or zero
*non-greedy*
@@ -674,7 +661,7 @@ overview.
The } may optionally be preceded with a backslash: \{n,m\}.
*/\@=*
-\@= Matches the preceding atom with zero width. {not in Vi}
+\@= Matches the preceding atom with zero width.
Like "(?=pattern)" in Perl.
Example matches ~
foo\(bar\)\@= "foo" in "foobar"
@@ -694,7 +681,7 @@ overview.
*/\@!*
\@! Matches with zero width if the preceding atom does NOT match at the
- current position. |/zero-width| {not in Vi}
+ current position. |/zero-width|
Like "(?!pattern)" in Perl.
Example matches ~
foo\(bar\)\@! any "foo" not followed by "bar"
@@ -724,7 +711,7 @@ overview.
*/\@<=*
\@<= Matches with zero width if the preceding atom matches just before what
- follows. |/zero-width| {not in Vi}
+ follows. |/zero-width|
Like "(?<=pattern)" in Perl, but Vim allows non-fixed-width patterns.
Example matches ~
\(an\_s\+\)\@<=file "file" after "an" and white space or an
@@ -768,7 +755,7 @@ overview.
\@<! Matches with zero width if the preceding atom does NOT match just
before what follows. Thus this matches if there is no position in the
current or previous line where the atom matches such that it ends just
- before what follows. |/zero-width| {not in Vi}
+ before what follows. |/zero-width|
Like "(?<!pattern)" in Perl, but Vim allows non-fixed-width patterns.
The match with the preceding atom is made to end just before the match
with what follows, thus an atom that ends in ".*" will work.
@@ -784,7 +771,7 @@ overview.
slow.
*/\@>*
-\@> Matches the preceding atom like matching a whole pattern. {not in Vi}
+\@> Matches the preceding atom like matching a whole pattern.
Like "(?>pattern)" in Perl.
Example matches ~
\(a*\)\@>a nothing (the "a*" takes all the "a"'s, there can't be
@@ -863,7 +850,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
/\(.\{-}\zsFab\)\{3}
< Finds the third occurrence of "Fab".
This cannot be followed by a multi. *E888*
- {not in Vi} {not available when compiled without the |+syntax| feature}
+ {not available when compiled without the |+syntax| feature}
*/\ze*
\ze Matches at any position, and sets the end of the match there: The
previous char is the last char of the whole match. |/zero-width|
@@ -872,17 +859,17 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
Example: "end\ze\(if\|for\)" matches the "end" in "endif" and
"endfor".
This cannot be followed by a multi. |E888|
- {not in Vi} {not available when compiled without the |+syntax| feature}
+ {not available when compiled without the |+syntax| feature}
*/\%^* *start-of-file*
\%^ Matches start of the file. When matching with a string, matches the
- start of the string. {not in Vi}
+ start of the string.
For example, to find the first "VIM" in a file: >
/\%^\_.\{-}\zsVIM
<
*/\%$* *end-of-file*
\%$ Matches end of the file. When matching with a string, matches the
- end of the string. {not in Vi}
+ end of the string.
Note that this does NOT find the last "VIM" in a file: >
/VIM\_.\{-}\%$
< It will find the next VIM, because the part after it will always
@@ -906,7 +893,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
*/\%#* *cursor-position*
\%# Matches with the cursor position. Only works when matching in a
- buffer displayed in a window. {not in Vi}
+ buffer displayed in a window.
WARNING: When the cursor is moved after the pattern was used, the
result becomes invalid. Vim doesn't automatically update the matches.
This is especially relevant for syntax highlighting and 'hlsearch'.
@@ -927,7 +914,6 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
< Note that two dots are required to include mark 'e in the match. That
is because "\%<'e" matches at the character before the 'e mark, and
since it's a |/zero-width| match it doesn't include that character.
- {not in Vi}
WARNING: When the mark is moved after the pattern was used, the result
becomes invalid. Vim doesn't automatically update the matches.
Similar to moving the cursor for "\%#" |/\%#|.
@@ -937,7 +923,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
\%<23l Matches above a specific line (lower line number).
\%>23l Matches below a specific line (higher line number).
These three can be used to match specific lines in a buffer. The "23"
- can be any line number. The first line is 1. {not in Vi}
+ can be any line number. The first line is 1.
WARNING: When inserting or deleting lines Vim does not automatically
update the matches. This means Syntax highlighting quickly becomes
wrong.
@@ -953,7 +939,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
These three can be used to match specific columns in a buffer or
string. The "23" can be any column number. The first column is 1.
Actually, the column is the byte number (thus it's not exactly right
- for multi-byte characters). {not in Vi}
+ for multi-byte characters).
WARNING: When inserting or deleting text Vim does not automatically
update the matches. This means Syntax highlighting quickly becomes
wrong.
@@ -975,7 +961,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
The "23" can be any column number. The first column is 1.
Note that some virtual column positions will never match, because they
are halfway through a tab or other character that occupies more than
- one screen character. {not in Vi}
+ one screen character.
WARNING: When inserting or deleting text Vim does not automatically
update highlighted matches. This means Syntax highlighting quickly
becomes wrong.
@@ -998,7 +984,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
where ".*" matches zero characters.
<
-Character classes: {not in Vi}
+Character classes:
\i identifier character (see 'isident' option) */\i*
\I like "\i", but excluding digits */\I*
\k keyword character (see 'iskeyword' option) */\k*
@@ -1058,7 +1044,7 @@ match ASCII characters, as indicated by the range.
*E51* *E54* *E55* *E872* *E873*
\1 Matches the same string that was matched by */\1* *E65*
- the first sub-expression in \( and \). {not in Vi}
+ the first sub-expression in \( and \).
Example: "\([a-z]\).\1" matches "ata", "ehe", "tot", etc.
\2 Like "\1", but uses second sub-expression, */\2*
... */\3*
@@ -1070,7 +1056,6 @@ match ASCII characters, as indicated by the range.
\%(\) A pattern enclosed by escaped parentheses. */\%(\)* */\%(* *E53*
Just like \(\), but without counting it as a sub-expression. This
allows using more groups and it's a little bit faster.
- {not in Vi}
x A single character, with no special meaning, matches itself
@@ -1171,7 +1156,7 @@ x A single character, with no special meaning, matches itself
backslash before it: "[xyz\]]", "[\^xyz]", "[xy\-z]" and "[xyz\\]".
(Note: POSIX does not support the use of a backslash this way). For
']' you can also make it the first character (following a possible
- "^"): "[]xyz]" or "[^]xyz]" {not in Vi}.
+ "^"): "[]xyz]" or "[^]xyz]".
For '-' you can also make it the first or last character: "[-xyz]",
"[^-xyz]" or "[xyz-]". For '\' you can also let it be followed by
any character that's not in "^]-\bdertnoUux". "[\xyz]" matches '\',
@@ -1180,7 +1165,7 @@ x A single character, with no special meaning, matches itself
- Omitting the trailing ] is not considered an error. "[]" works like
"[]]", it matches the ']' character.
- The following translations are accepted when the 'l' flag is not
- included in 'cpoptions' {not in Vi}:
+ included in 'cpoptions':
\e <Esc>
\t <Tab>
\r <CR> (NOT end-of-line!)
@@ -1261,7 +1246,7 @@ files. To match a <Nul> with a search pattern you can just enter CTRL-@ or
"CTRL-V 000". This is probably just what you expect. Internally the
character is replaced with a <NL> in the search pattern. What is unusual is
that typing CTRL-V CTRL-J also inserts a <NL>, thus also searches for a <Nul>
-in the file. {Vi cannot handle <Nul> characters in the file at all}
+in the file.
*CR-used-for-NL*
When 'fileformat' is "mac", <NL> characters in the file are stored as <CR>