When Jamis Buck switched from TextMate to vim, he found he missed one bit of functionality above all others: TextMate’s file finder, Cmd+T.
Being a capable programmer, he “took an evening” and wrote up a Ruby library to replicate this functionality. Then he extended vim with a plugin called fuzzyfinder_textmate that called out to this Ruby library.
The results were terrific, and fuzzyfinder_textmate is my go-to solution for opening files in vim. I almost never type “:e …” anymore. I’ve yet to see anything faster at grabbing a file buried somewhere in a directory tree. This plugin is particularly useful for me when working on Rails projects, where vim’s ‘current directory’ is Rails.root, and everything I want to open is down at least one level. If you’re not familiar with the plugin, here’s a silent-movie-style screencast Jamis put together when he released it.
Sadly, this terrific plugin has a bit of a problem: it’s a pain in the ass to install.
Jamis’ fuzzyfinder_textmate relies on a second plugin, called fuzzyfinder.vim. The author of this plugin makes frequent changes, which usually end up breaking fuzzyfinder_textmate. This got to be too much for Jamis, and he officially dropped the project a year ago. Today, the latest versions of these plugins won’t work together.
However, thanks to several contributors and github’s forking, you can get this big mish-mash of libraries and plugins to work…provided you install exactly the right versions of each. It’s a trifle annoying, but fortunately I’ve done the homework for you. Follow the steps below and enjoy my favorite bit of vim functionality.
Installing fuzzyfinder_textmate:
- Make sure you’re using vim 7.2 (the latest, as of this writing). It’s possible earlier versions work as well, but I can’t confirm these steps will apply.
- Make sure the vim you installed was compiled with ruby support. Check this by running vim –version | grep ruby at the command line. A result of +ruby means you’re good, -ruby means you DON’T have ruby support. Debian/Ubuntu users can get a ruby-capable vim by running sudo apt-get install vim-ruby. Another test to make sure you’ve got ruby support: type :ruby in vim. Argument required is good. Not an editor command: ruby is bad.
- Install Jamis’ fuzzy_file_finder Ruby library from here. This is installable as a gem, but I strongly recommend simply git cloneing this repo, creating a ruby directory in your .vim folder, and placing the lib/fuzzy_file_finder.rb inside there. This keeps this dependency in your .vim directory (rather than on a system gem you’ll forget about when you change servers), and enables keeping your vim configuration in a git repository (HIGHLY recommended).
- Install vim-fuzzyfinder version 2.22.3. IMPORTANT: you MUST use this exact version. Other versions (particularly anything NEWER than this one) will NOT work. After installing, confirm it works by running :FuzzyFinderFile in vim. You should get a pop up box with a list of files. If you do you’re almost there.
- Install fuzzyfinder_textmate, but use sethbc’s fork from github. Don’t use the version from Jamis’ repo as it will NOT work with the version of fuzzyfinder.vim we installed. git clone again, and simply put fuzzyfinder_textmate.vim in your .vim/plugin folder. To test that everything worked, run :FuzzyFinderTextMate in vim. If you get a popup box, you’re done!
If you’re having trouble, the most common culprit is that you’ve mucked up the versions. This collection of files is quite finicky, and if you’re using the wrong version of any one things fall apart quickly. After that, double-check you’ve got Ruby support.
If you’re still having trouble, do a git clone of my dotfiles. My setup is confirmed working, so you can diff your copies of the library/plugins against mine. Any differences mean you’ve got the wrong version.
If you still have issues, leave a note in the comments and I’ll try to get you sorted out.
Finally, if you found this post useful, I’d urge you to check out my screencast: Vim for Rails Developers. In it, I’ll teach you the best plugins, external tools, and editing tricks for writing Rails code at top-speed. If you write Rails code in vim, it’s sure to save you time.
10 Comments
Thanks for this!
Does this plugin only work on small projects? It is fine when I use it in a small directory, but when I call :FuzzyFileFinderTextmate in a larger one I get:
Error detected while processing function 21_CompleteFunc..109..192:
line 22:
FuzzyFileFinder::TooManyEntries: FuzzyFileFinder::TooManyEntries
Nice article. Coincidentally, I recently happened upon a video discussing emacs’ own equivalent to TextMate’s Cmd+T: http://www.vimeo.com/1013263
Paul: fuzzyfinder_textmate sets a ceiling of 10,000 files to scan before raising that error. If you need to bump it up, add “let g:fuzzy_ceiling = (some_big_number)” to your .vimrc
You should try out the g:fuf_splitPathMatching option to FuzzyFinder 3.5. It does pretty much what fuzzyfinder_textmate does, only without doing a 5-step complicated setup. If you find any differences, please let me know. It’s probably an easy fix.
Henrik: How exactly do you get it to match all files recursively in a directory?
I noticed that I am able to see a file drop down and select different files, but pressing enter doesn’t jump to a file, it puts me an insert mode.
I’ve gone over my vimrc a few times but I don’t see what the culprit is, any ideas? Thanks!
Henrik: it looks as though g:fuf_splitPathMatching is enabled by default in FuzzyFinder 3.5. The documentation states that “[TextMate cmd-T matching occurs] in a mode which targets a static set of file paths (such as Buffer or MRU-File mode, not File or Directory)”. In other words, cmd-T style matching works on the list of files which have been opened in a Vim session. The fuzzyfinder_textmate plugin does cmd-T matching on all files below the current working directory (up to a limit). Am I missing something?
Frederik: enter **/ after :FufFile, which matches all files recursively. Then refine your search. **/app for example matches every file or dir with ‘app’ in it’s name.
I find fuzzyfinder_textmate a bit smarter though.
Hello!
Thanks for the awesome tutorial. I ran into one slight problem – Vim couldn’t find msvcrt-ruby18.dll (I’m running Windows). I use Ruby 1.9, and that’s what I have on my PATH – so dropping msvcrt-ruby18.dll into my 1.9 bin/ did the trick.
I’m sure this will cause some problems down the road though. Do you know how to make Vim use another path?
Thanks,
-Charles
Charles — Sorry, no idea. I don’t run any Windows machine anymore. Maybe someone else can chime in with an answer.
One Trackback/Pingback
[...] Installing fuzzyfinder_textmate: Textmate’s Cmd+T in Vim [...]
Post a Comment