fzy is a fast, simple fuzzy text selector for the terminal with an advanced scoring algorithm.
在線嘗試!
這是一種改變生活的。 - @Graygilmore
fzy工作很棒,順便說一句 - @Alexblackie
FZY比其他模糊發現器更快,並且顯示出更好的結果。
大多數其他模糊匹配器根據比賽的長度進行排序。 FZY試圖找到用戶預期的結果。它是通過在連續字母和單詞開始的情況下偏愛匹配來做到這一點的。這允許使用縮寫詞或路徑的不同部分進行匹配。
可以在algorithm.md中找到對模糊發現器使用的分類的血腥比較
FZY旨在將其用作編輯插件和命令行。 FZY沒有清除屏幕,而是直接在當前光標位置下方顯示其接口,而是在必要時滾動屏幕。
macos
使用自製
brew install fzy
使用MacPorts
sudo port install fzy
Arch Linux/MSYS2 : pacman -S fzy
FreeBSD : pkg install fzy
Gentoo Linux : emerge -av app-shells/fzy
Ubuntu/Debian : apt-get install fzy
pkgsrc (NetBSD and others) : pkgin install fzy
openSUSE : zypper in fzy
make
sudo make install
The PREFIX environment variable can be used to specify the install location, the default is /usr/local .
FZY是替換選擇的替代品,可以與其使用示例一起使用。
FZY可以很容易地與VIM集成。
function ! FzyCommand (choice_command, vim_command)
try
let output = system ( a: choice_command . " | fzy " )
catch /Vim:Interrupt/
" Swallow errors from ^C, allow redraw! below
endtry
redraw !
if v: shell_error == 0 && ! empty (output)
exec a: vim_command . ' ' . output
endif
endfunction
nnoremap <leader> e :call FzyCommand("find . -type f", ":e") <cr>
nnoremap <leader> v :call FzyCommand("find . -type f", ":vs") <cr>
nnoremap <leader> s :call FzyCommand("find . -type f", ":sp") <cr>任何程序都可以用於過濾通過FZY顯示的文件。 ag (the silver searcher) can be used to ignore files specified by .gitignore .
nnoremap <leader> e :call FzyCommand("ag . --silent -l -g ''", ":e") <cr>
nnoremap <leader> v :call FzyCommand("ag . --silent -l -g ''", ":vs") <cr>
nnoremap <leader> s :call FzyCommand("ag . --silent -l -g ''", ":sp") <cr> FZY試圖首先提出最佳比賽。排序時以下考慮因素是加權的:
It prefers consecutive characters: file will match file over fil t e r .
It prefers matching the beginning of words: amp is likely to match a pp/ m odels/ p osts.rb .
It prefers shorter matches: abce matches abc d e f over abc d e .
It prefers shorter candidates: test matches test s over test ing .