使用模糊搜索在Vim中打开文件 [英] Opening files in Vim using Fuzzy Search
问题描述
我正在寻找一种方法,使Vim能够通过模糊搜索文件名来打开文件。
I'm looking for a way to make Vim have the ability to open a file by fuzzy-searching its name.
基本上,我希望能够一次定义一个项目,然后有一个快捷方式,该快捷方式将为我提供一个键入文件名的地方,并且如果有字母匹配的话,也将匹配。
Basically, I want to be able to define a project once, and then have a shortcut which will give me a place to type a file name, and will match if any letters match up.
这种功能在我见过的大多数编辑器中都存在,但是对于我一生来说,我不知道如何让Vim做到这一点。
This kind of functionality exists in most editors I've seen, but for the life of me I can't understand how to get Vim to do this.
请注意,我在寻找不会的某些内容要求我知道文件在目录树中的位置。我只希望能够通过文件名打开它,而不管它在哪个目录中。
Note that I'm looking for something that won't require me to have any idea where in my directory tree a file is. I just want to be able to open it by the filename, regardless of what directory it's in.
谢谢
推荐答案
有两个很棒的vim插件。
There are two great vim plugins for this.
ctrlp :
ctrlp:
- 以纯VimL编写
- 几乎可以在任何地方工作
- 支持自定义查找器以提高性能
- 最流行的Vim模糊搜索插件
- Written in pure VimL
- Works pretty much everywhere
- Supports custom finders for improved performance
- Most popular fuzzy search plugin for Vim
Command-T:
- 用C,VimL和Ruby语言编写
- 开箱即用
- 在Vim中需要
+ ruby
支持 - 推荐Vim版本> =
7.3
- Written in C, VimL and Ruby
- Fast out of the box
- Requires
+ruby
support in Vim - Recommends Vim version >=
7.3
编辑:
我使用 CtrlP 与 ag 作为我的自定义查找器,它的运行速度非常快(即使在大型项目中也是如此)并且非常便携。
I use CtrlP with ag as my custom finder and it's incredibly quick (even on massive projects) and very portable.
将 ag 与< a href = https://github.com/ctrlpvim/ctrlp.vim rel = noreferrer> CtrlP :
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
这篇关于使用模糊搜索在Vim中打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!