FZY是具有高级评分算法的终端的快速,简单的模糊文本选择器。
在线尝试!
这是一种改变生活的。 - @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等) : pkgin install fzy
opensuse : zypper in fzy
make
sudo make install
PREFIX环境变量可用于指定安装位置,默认值为/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(银搜索器)可用于忽略.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试图首先提出最佳比赛。排序时以下考虑因素是加权的:
它更喜欢连续的字符: file将匹配文件而不是file t e r 。
它更喜欢匹配单词的开头: amp可能与PP / M ODELS/ P OSTS.RB匹配。
它更喜欢较短的匹配: abce匹配ABC D E F而不是ABC D e 。
它更喜欢较短的候选者: test匹配测试而不是测试。