Faster Ctrlp.vim for Rails Projects

Written by

Ctrlp is a fuzzy finding file matcher that pops up at the bottom of vim when it’s control p is pressed (or your custom binding). It’s a huge timesaver to quickly be able to jump to to app/assets/javascript/views/outfitsView.js by hitting control p then ofsvjs.

One frustration with ctrlp is that it tries to index everything but stops at around 6000 files (by breadth first serach). This can leave files deep in your directory structure unavailable and add frustrating results to the listing. Luckily, it’s easy to fix with per project vimrc files.

  1. Allow per project vimrc’s. In your main .vimrc add:

     " enable per-project .vimrc files
     set exrc
     " Only execute safe per-project vimrc commands
     set secure
  2. Add a .vimrc to your project root and add:

     set wildignore+=tags
     set wildignore+=*/tmp/*
     set wildignore+=*/vendor/*
     set wildignore+=*/spec/vcr/*
     set wildignore+=*/public/*
     set wildignore+=*/chef/*
     set wildignore+=*/coverage/*
     set wildignore+=*.png,*.jpg,*.otf,*.woff,*.jpeg,*.orig

You might need to adjust the vimrc to suit your project. This has been a huge timesaver for me and resulted in faster file finding and more relevant results.

On final tip, if after adding this you still don’t seem the right results you may need to clear the ctrlp cache. You can do this by going into ~/.cache/ctrlp/ and removing any files that match your directory name.


Comments or Questions? Contact Nick @nixterrimus on twitter.

Nick is a software engineer, geek, web enthusaist, open source contributor, home automation tinkerer, ocean admirer and all around general optimist living in San Francisco. Want to get in touch about professional matters? Nick Rowe is also available on LinkedIn.