Install CtrlP to save time hunting for files in Vim
Vim is my favorite text editor. I've used it exclusively since 2004, having fallen in love with its near-infinite customizability and "one tool, one job" philosophy.
But if there's one feature that's always felt missing, it's a great fuzzy file
search. Other text editors like Atom, TextMate, and Sublime offer the user a
convenient way to search files by typing partial substrings of the full
filename. So if you have a file in
foobaz into the
fuzzy finder would find the file.
reducers/todos.js actions/todos.js components/TodoList.js
Using tab completion to resolve these paths works, but it's a lot of keyboard crunching. Not the smoothest approach.
Luckily, CtrlP offers a turnkey solution.
To install CtrlP, clone it into your
git clone https://github.com/ctrlpvim/ctrlp.vim.git ~/.vim/bundle/ctrlp.vim
Then, add it to your Vim's runtime path in your
You'll probably also want to tell CtrlP to ignore files matching some paths by
wildignore option in your
This tells CtrlP to ignore version control meta files (Git/Mercurial/SVN), files
build directories (I use Middleman
frequently and it dumps its output files here), and your NPM
directory. If you have other project-specific paths you don't want to show up in
your fuzzy search results, add them here.
To use CtrlP, open Vim in the root directory of the codebase of your choice and
Ctrl+P. A buffer will appear at the bottom of your Vim. Type some
characters that are a part of the file you want to find, and you'll see the list
of files reduce to those matching your query. Press Return and the selected file
Hopefully CtrlP will improve your workflow like it has improved mine. Reducing the friction between your brain and your fingers is paramount in creating a work environment that enables great work instead of getting the way. Cheers!