Fork me on GitHub

Today I learned: Vim

Fuzzy finding with FZF.vim Wed, 06 Jan 2016

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!


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.

Opening URLs from Vim Sun, 08 Feb 2015

Tmux and Vim: the perfect combination Wed, 30 Jul 2014

Ruby text objects Fri, 18 Jul 2014

Recording Macros for Super Efficiency Thu, 01 May 2014

Better Pasting from the Clipboard Tue, 18 Mar 2014

vim-dispatch: I should have used this years ago Thu, 13 Mar 2014

Repeating last command-line with `@:` Wed, 29 Jan 2014

Automatic Comment Prefixing Revisited Mon, 30 Dec 2013

Swapping Pathogen for Vundle Sat, 28 Dec 2013

Jumping to last cursor position Fri, 27 Dec 2013

The CamelCase Motion Plugin Fri, 20 Dec 2013

In Place code execution with Pipe2Eval Tue, 27 Aug 2013

Clearing the Search Highlight Thu, 22 Aug 2013

Awesome JS Auto Completion Wed, 21 Aug 2013

Swapping background quickly Wed, 31 Jul 2013

Live in-place Ruby execution Mon, 24 Jun 2013

Searching again with // Thu, 20 Jun 2013

Ways to quit Wed, 05 Jun 2013

Vim's `lcd` command Tue, 04 Jun 2013

vim-ruby Thu, 30 May 2013

Automatic Comment Prefixing Wed, 29 May 2013

Sorting a selection Fri, 24 May 2013

Stop Vim being slow when using rbenv Mon, 20 May 2013

Making `j` and `k` work on visual lines Thu, 16 May 2013

Aliasing g Thu, 02 May 2013

Deleting Lines that don't Match a Pattern Wed, 01 May 2013

Vim Scratch Plugin Tue, 30 Apr 2013

Binding Caps-lock to Control and Escape Mon, 29 Apr 2013

Extending Visual Selections with 'o' Fri, 26 Apr 2013

Vim Startify Thu, 25 Apr 2013

Easier Reindenting Wed, 24 Apr 2013

The Command Window Wed, 24 Apr 2013

Subscribe: RSS Feed.

TIL: Vim is another side project by Jack Franklin.

I'm by no means a Vim expert, but wanted to share the things I learn in Vim as I attempt to get better and more efficient using it. I figured documenting it somewhere where others can see and contribute was a good way to do it.