Command-T is a vim plugin for rapid file navigation using fuzzy path matching. It is one of the few plugins I find truly essential. Although profoundly useful, I find that there are a few customizations that make it unbeatable.
In order to make Command-T a little more friendly, I do the following:
- Make all Command-T actions relative the current git repo root
- Use the
.gitignoreto filter the file list
- Setup a collection of maps for starting Command-T in subfolders
Command-T Relative the Git Root
The first thing I do in order to make working with Command-T more friendly is to make it work from the root of the current git repo. Reaching for Commend-T implies that I am in a project of some non trivial size, ie anything with one or more subfolders, then I can pretty safely assume I will have it in a git repo.
The following functions allow me to move the current working directory to the root of the git repo before starting up Command-T.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Using the .gitignore
By default, Command-T will use the vim
wildignore setting to filter files
from the Command-T list. This means that there will only be one global filter
used in every vim session to filter things out. This can be an issue when
working with things like an Octopress blog (like this one), a Rails 3.1 app, or
anything else that has build output or other numerous files that will be in the
I was able to track down a vim plugin create by Adam Bellaire that can parse a
gitignore and use it to define the vim
wildignore setting. His original
script can be found
here, but since it only
included a single function I just included that directly in my vimrc. What
follows is my version of Adam’s original script, wrapped up as a vim function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Subfolder Focused Command-T Mappings
This last piece was inspired by a Destroy All Software screencast by Gary Bernhardt. I highly recommend anything by Gary Bernhardt.
1 2 3 4 5 6 7 8
All in all I am very happy with where I am at with file navigation. I barely have to think at this point to get to a file, and that’s the way I like it. You can checkout the full details of this and my other vim configs in my vimrc.
Room for Improvement
The one major issue I have with my current Command-t usage outlined above is
the need to explicitly fire the Command-t from gitignore function. I would like
to set this to fire based on an autocommand or by hooking into vims
trigger it automatically. I would imagine it would be necessary to cache the
current project in order to avoid doing this all the time. As of now I haven’t
felt a strong enough pull to figure this out, but I expect I will revisit it