vimeditortext-editorfuzzy-search

Opening files in Vim using Fuzzy Search


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.

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.

Thanks


Solution

  • There are two great vim plugins for this.

    ctrlp:

    Command-T:

    EDIT:

    I use CtrlP with ag as my custom finder and it's incredibly quick (even on massive projects) and very portable.

    An example of using ag with 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