Home Explore Blog CI



neovim

11th chunk of `runtime/doc/pattern.txt`
0bf90d3238059f77a1600982a1dd65a19a3abfe9a086dfcb0000000100000fa1
 engine works differently, it is better to not
	rely on this behavior, do not use \@<= if it can be avoided:
	Example				matches ~
	\([a-z]\+\)\zs,\1		",abc" in "abc,abc"

\@123<=
	Like "\@<=" but only look back 123 bytes.  This avoids trying lots
	of matches that are known to fail and make executing the pattern very
	slow.  Example, check if there is a "<" just before "span":
		/<\@1<=span
	This will try matching "<" only one byte before "span", which is the
	only place that works anyway.
	After crossing a line boundary, the limit is relative to the end of
	the line.  Thus the characters at the start of the line with the match
	are not counted (this is just to keep it simple).
	The number zero is the same as no limit.

							*/\@<!*
\@<!	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|
	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.
	Warning: This can be slow (because many positions need to be checked
	for a match).  Use a limit if you can, see below.
	Example			matches ~
	\(foo\)\@<!bar		any "bar" that's not in "foobar"
	\(\/\/.*\)\@<!in	"in" which is not after "//"

\@123<!
	Like "\@<!" but only look back 123 bytes.  This avoids trying lots of
	matches that are known to fail and make executing the pattern very
	slow.

							*/\@>*
\@>	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
			another one following)

	This matches the preceding atom as if it was a pattern by itself.  If
	it doesn't match, there is no retry with shorter sub-matches or
	anything.  Observe this difference: "a*b" and "a*ab" both match
	"aaab", but in the second case the "a*" matches only the first two
	"a"s.  "\(a*\)\@>ab" will not match "aaab", because the "a*" matches
	the "aaa" (as many "a"s as possible), thus the "ab" can't match.


==============================================================================
6.  Ordinary atoms					*pattern-atoms*

An ordinary atom can be:

							*/^*
^	At beginning of pattern or after "\|", "\(", "\%(" or "\n": matches
	start-of-line; at other positions, matches literal '^'. |/zero-width|
	Example		matches ~
	^beep(		the start of the C function "beep" (probably).

							*/\^*
\^	Matches literal '^'.  Can be used at any position in the pattern, but
	not inside [].

							*/\_^*
\_^	Matches start-of-line. |/zero-width|  Can be used at any position in
	the pattern, but not inside [].
	Example		matches ~
	\_s*\_^foo	white space and blank lines and then "foo" at
			start-of-line

							*/$*
$	At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
	matches end-of-line <EOL>; at other positions, matches literal '$'.
	|/zero-width|

							*/\$*
\$	Matches literal '$'.  Can be used at any position in the pattern, but
	not inside [].

							*/\_$*
\_$	Matches end-of-line. |/zero-width|  Can be used at any position in the
	pattern, but not inside [].  Note that "a\_$b" never matches, since
	"b" cannot match an end-of-line.  Use "a\nb" instead |/\n|.
	Example		matches ~
	foo\_$\_s*	"foo" at end-of-line and following white space and
			blank lines

.	(with 'nomagic': \.)				*/.* */\.*
	Matches any single character, but not an end-of-line.

							*/\_.*
\_.	Matches any single character or end-of-line.
	Careful: "\_.*" matches all text to the end of the buffer!

							*/\<*
\<	Matches the beginning of a word: The next char is the first char of a
	word.  The 'iskeyword' option specifies what is a word character.
	|/zero-width|

							*/\>*
\>	Matches the end of a word: The previous char is the last char of a
	word.  The 'iskeyword' option

Title: Vim Regular Expression Zero-Width Matches and Ordinary Atoms: @<!, @>, ^, $, ., <, >
Summary
This section continues the discussion on zero-width matching items in Vim regular expressions with @<! and @>, providing examples of their usage and limitations. It also covers ordinary atoms, including anchors (^ and $) for matching the start and end of lines, the dot (.) for matching any single character, and \< and \> for matching the beginning and end of words.