Home Explore Blog CI



neovim

22th chunk of `runtime/doc/pattern.txt`
7818cca9460163ffb1cbcfb6374fdce7d6aa671e7c73f5ad0000000100000c4b
 limited to three
		matches (aside from |:match|, |:2match| and |:3match| are
		available).  |matchadd()| does not have this limitation and in
		addition makes it possible to prioritize matches.

		Another example, which highlights all characters in virtual
		column 72 and more: >
			:highlight rightMargin term=bold ctermfg=blue guifg=blue
			:match rightMargin /.\%>72v/
<		To highlight all character that are in virtual column 7: >
			:highlight col8 ctermbg=grey guibg=grey
			:match col8 /\%<8v.\%>7v/
<		Note the use of two items to also match a character that
		occupies more than one virtual column, such as a TAB.

:mat[ch]
:mat[ch] none
		Clear a previously defined match pattern.


:2mat[ch] {group} /{pattern}/					*:2match*
:2mat[ch]
:2mat[ch] none
:3mat[ch] {group} /{pattern}/					*:3match*
:3mat[ch]
:3mat[ch] none
		Just like |:match| above, but set a separate match.  Thus
		there can be three matches active at the same time.  The match
		with the lowest number has priority if several match at the
		same position.  It uses the match id 3.
		The ":3match" command is used by (older Vims) |matchparen|
		plugin.  You are suggested to use ":match" for manual matching
		and ":2match" for another plugin or even better make use of
		the more flexible |matchadd()| (and similar) functions instead.

==============================================================================
11. Fuzzy matching					*fuzzy-matching*

Fuzzy matching refers to matching strings using a non-exact search string.
Fuzzy matching will match a string, if all the characters in the search string
are present anywhere in the string in the same order.  Case is ignored.  In a
matched string, other characters can be present between two consecutive
characters in the search string.  If the search string has multiple words, then
each word is matched separately.  So the words in the search string can be
present in any order in a string.

Fuzzy matching assigns a score for each matched string based on the following
criteria:
    - The number of sequentially matching characters.
    - The number of characters (distance) between two consecutive matching
      characters.
    - Matches at the beginning of a word
    - Matches at a camel case character (e.g. Case in CamelCase)
    - Matches after a path separator or a hyphen.
    - The number of unmatched characters in a string.
    - A full/exact match is preferred.
The matching string with the highest score is returned first.

For example, when you search for the "get pat" string using fuzzy matching, it
will match the strings "GetPattern", "PatternGet", "getPattern", "patGetter",
"getSomePattern", "MatchpatternGet" etc.

The functions |matchfuzzy()| and |matchfuzzypos()| can be used to fuzzy search
a string in a List of strings.  The matchfuzzy() function returns a List of
matching strings.  The matchfuzzypos() functions returns the List of matches,
the matching positions and the fuzzy match scores.

The "f" flag of `:vimgrep` enables fuzzy matching.

To enable fuzzy matching for |ins-completion|, add the "fuzzy" value to the
'completeopt' option.

 vim:tw=78:ts=8:noet:ft=help:norl:

Title: Limitations of :match, Fuzzy Matching Explanation
Summary
The text discusses the limitations of the `:match` command, noting that it is limited to three matches (using `:match`, `:2match`, and `:3match`). `matchadd()` doesn't have this limit and allows prioritizing matches. It then provides examples of highlighting virtual columns using `:match`. The `:match none` command is explained as clearing a previously defined match pattern. Finally, it introduces the concept of fuzzy matching, explaining how it works, the criteria used for scoring matches, and the functions (`matchfuzzy()` and `matchfuzzypos()`) and features (the "f" flag of `:vimgrep` and the 'completeopt' option for |ins-completion|) available for using fuzzy matching.