found is used:
- The keyword currently under the cursor.
- The first keyword to the right of the cursor, in the same line.
- The WORD currently under the cursor.
- The first WORD to the right of the cursor, in the same line.
The keyword may only contain letters and characters in 'iskeyword'.
The WORD may contain any non-blanks (<Tab>s and/or <Space>s).
Note that if you type with ten fingers, the characters are easy to remember:
the "#" is under your left hand middle finger (search to the left and up) and
the "*" is under your right hand middle finger (search to the right and down).
(this depends on your keyboard layout though).
*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*
*E383* *E476*
For starters, read chapter 27 of the user manual |usr_27.txt|.
*/bar* */\bar* */pattern*
1. A pattern is one or more branches, separated by "\|". It matches anything
that matches one of the branches. Example: "foo\|beep" matches "foo" and
matches "beep". If more than one branch matches, the first one is used.
pattern ::= branch
or branch \| branch
or branch \| branch \| branch
etc.
*/branch* */\&*
2. A branch is one or more concats, separated by "\&". It matches the last
concat, but only if all the preceding concats also match at the same
position. Examples:
"foobeep\&..." matches "foo" in "foobeep".
".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob"
branch ::= concat
or concat \& concat
or concat \& concat \& concat
etc.
*/concat*
3. A concat is one or more pieces, concatenated. It matches a match for the
first piece, followed by a match for the second piece, etc. Example:
"f[0-9]b", first matches "f", then a digit and then "b".
concat ::= piece
or piece piece
or piece piece piece
etc.
*/piece*
4. A piece is an atom, possibly followed by a multi, an indication of how many
times the atom can be matched. Example: "a*" matches any sequence of "a"
characters: "", "a", "aa", etc. See |/multi|.
piece ::= atom
or atom multi
*/atom*
5. An atom can be one of a long list of items. Many atoms match one character
in the text. It is often an ordinary character or a character class.
Parentheses can be used to make a pattern into an atom. The "\z(\)"
construct is only for syntax highlighting.
atom ::= ordinary-atom |/ordinary-atom|
or \( pattern \) |/\(|
or \%( pattern \) |/\%(|
or \z( pattern \) |/\z(|
*/\%#=* *two-engines* *NFA*
Vim includes two regexp engines:
1. An old, backtracking engine that supports everything.
2. A new, NFA engine that works much faster on some patterns, possibly slower
on some patterns.
*E1281*
Vim will automatically select the right engine for you. However, if you run
into a problem or want to specifically select one engine or the other, you can
prepend one of the following to the pattern:
\%#=0 Force automatic selection. Only has an effect when
'regexpengine' has been set to a non-zero value.
\%#=1 Force using the old engine.
\%#=2 Force using the NFA engine.
You can also use the 'regexpengine' option to change the default.
*E864* *E868* *E874* *E875* *E876* *E877* *E878*
If selecting the NFA engine and it runs into something that is not implemented
the pattern will not match. This is only useful when debugging Vim.
==============================================================================