I’ve been through my fair share of Vim file finding plugins. I first started with Command-T before moving on to CtrlP. I then stole a colleague’s set up which used Gary Bernhardt’s selecta finder. You can find the config for that in my old vimrc.

That had been serving me well but I then stumbled upon Junegunn Choi’s excellent fzf, a great fuzzy finder that (from my experience so far) seems incredibly quick and extremely reliable. Thankfully he’s also created fzf.vim, a Vim wrapper around some common functionality that fzf provides. It’s this that I want to show you today.

Installing is fairly straight forward, and it’s recommended you use Vim-Plug to do it:

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim'

Once done you’ll have access to a bunch of new commands that will use fzf to find files, lines and more.

Finding Files

You can use the :Files command to search for files in your directory.

Finding Commits

I’m also a big fan of the :Commits command, which fuzzy searches through your git commits. Note that you need Fugitive.vim for this to work.

Matching Lines

You can also use the plugin in insert mode to perform linewise completition based on what you’ve already typed! I’ve mapped this like so:

imap <c-x><c-l> <plug>(fzf-complete-line)

As shown in the fzf.vim README. This is really useful when you need to type a line you know you’ve typed before - for example, an import or require statement. This is effectively Vim’s linewise completion on overdrive!

Conclusion

fzf.vim has really added a lot to my Vim setup and workflow - once you get used to fuzzy finding everything you’ll never look back, and I highly recommend giving it a go.