As a developer, I’m often bouncing between numerous files, looking for a specific item in a massive codebase, or trying to remember that arcane command I ran once months ago.
There are a handful of fuzzy find tools, either from builtin editor features or via the shell, but they often suffer from unfortunate limitations. Whether slow performance or having cache results get out of date, they often require accepting tradeoffs.
Enter FZF, a modern fuzzy finder written in Go that is not only incredibly fast but also very customizable.
With shell bindings and the ability to tie into Vim, it’s sped up our workflow at Headway quite a bit. Searching for a file by name in a project is nearly instantaneous, and it’s easy to pull up a command in your shell history with a few keystrokes.
Here’s how I’m using it in my environment:
I manage my Vim plugins using vim-plug which is a simple manager that installs plugins in parallel. It also has the ability to run post-install hooks to manage external libraries. Using it to install and manage FZF is straightforward:
In your .vimrc:
Running :PlugInstall in Vim will then copy FZF into the .fzf directory in your home folder and then run its post-install script to configure the native executable. FZF comes with basic Vim bindings out of the box, but I like to make a few changes:
In your .vimrc:
This maps the FZF search to Ctrl-F, and sets up hotkeys for opening splits in Vim similar to others I’m used to using. With only those few lines, searching for any file within the root directory becomes a breeze.
When vim-plug installs FZF, it also makes it available for use on your PATH as well. With a few entries in Zsh’s config, we can tie command history search into FZF:
In your .zshrc:
This sets up Zsh’s history search on Ctrl-R and then runs the FZF zshell script to configure FZF for it.
Now that we have our fuzzy find in place, there’s a good chance we’ll want to exclude certain entries from the results. Library dependencies, the .git directory, and others can be easily left out by setting the FZF_DEFAULT_COMMAND environment variable:
In your .zshrc:
Add any other directories you want ignored with -o -name directory_name -prune.
Simple tools can make all the difference in being productive and covering ground quickly. I’ve found FZF to be a huge asset towards that goal, and it’s worth the investment to get a handle on it.
Discover a proven method to help you prioritize which features to build first so you can get a faster return on your investment.
Start gaining traction in the most important parts of your startup. In this free video series, learn proven tactics that will impact real business growth.
Give your startup a competitive advantage. In this free video series, learn the common mistakes we see and give yourself a greater chance for success.
See all the ways we can help you grow through design, development, marketing, and more.
A podcast about building successful software. We provide actionable advice around product validation, execution, and promotion.
A show where we go behind the scenes on what it really takes to bring a new product to market.
Receive the latest articles, resources, events, and more!