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: