mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
docs(fuzzy-match): cherry-pick latest changes
53f7fccc94
1b884a0053
4c295027a4
3ec3217f04
This commit is contained in:
parent
ce797e08f5
commit
02e7431445
@ -4862,7 +4862,7 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
|
|||||||
GetText()->matchend('word')
|
GetText()->matchend('word')
|
||||||
|
|
||||||
matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
|
matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
|
||||||
If {list} is a list of strings, then returns a list with all
|
If {list} is a list of strings, then returns a |List| with all
|
||||||
the strings in {list} that fuzzy match {str}. The strings in
|
the strings in {list} that fuzzy match {str}. The strings in
|
||||||
the returned list are sorted based on the matching score.
|
the returned list are sorted based on the matching score.
|
||||||
|
|
||||||
@ -4895,6 +4895,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
|
|||||||
empty list is returned. If length of {str} is greater than
|
empty list is returned. If length of {str} is greater than
|
||||||
256, then returns an empty list.
|
256, then returns an empty list.
|
||||||
|
|
||||||
|
Refer to |fuzzy-match| for more information about fuzzy
|
||||||
|
matching strings.
|
||||||
|
|
||||||
Example: >
|
Example: >
|
||||||
:echo matchfuzzy(["clay", "crow"], "cay")
|
:echo matchfuzzy(["clay", "crow"], "cay")
|
||||||
< results in ["clay"]. >
|
< results in ["clay"]. >
|
||||||
|
@ -1421,5 +1421,38 @@ Finally, these constructs are unique to Perl:
|
|||||||
are suggested to use ":match" for manual matching and
|
are suggested to use ":match" for manual matching and
|
||||||
":2match" for another plugin.
|
":2match" for another plugin.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
11. Fuzzy matching *fuzzy-match*
|
||||||
|
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -1014,6 +1014,13 @@ commands can be combined to create a NewGrep command: >
|
|||||||
updated. With the [!] any changes in the current
|
updated. With the [!] any changes in the current
|
||||||
buffer are abandoned.
|
buffer are abandoned.
|
||||||
|
|
||||||
|
'f' When the 'f' flag is specified, fuzzy string
|
||||||
|
matching is used to find matching lines. In this
|
||||||
|
case, {pattern} is treated as a literal string
|
||||||
|
instead of a regular expression. See
|
||||||
|
|fuzzy-match| for more information about fuzzy
|
||||||
|
matching strings.
|
||||||
|
|
||||||
|QuickFixCmdPre| and |QuickFixCmdPost| are triggered.
|
|QuickFixCmdPre| and |QuickFixCmdPost| are triggered.
|
||||||
A file that is opened for matching may use a buffer
|
A file that is opened for matching may use a buffer
|
||||||
number, but it is reused if possible to avoid
|
number, but it is reused if possible to avoid
|
||||||
|
Loading…
Reference in New Issue
Block a user