Fixing Command-T for Vim in Ubuntu 12.04

The Command-T Vim plugin gives you a TextMate style “Fuzzy search” for files in the current directory tree. Basically, you can hit a button and start typing the bits of the file name you remember and Command-T will show you a set of search results.

On my first attempt to build and use Command-T it caused a seg-fault whenever I activated it. This is because Vim in the Ubuntu apt repo was built with the ancient ruby 1.8.7-p352, and Command-T only works when run under the same version which Vim was built with. If you install vim (or gvim/vim-gnome) from the package repos but get ruby from somewhere else, you’ll need to do the following:

  1. Get a copy of Command-T by following the readme. I use pathogen to load my vim plugins, so I cloned the Command-T git repo in my .vim/bundle folder.
  2. Navigate into the folder Command-T extracted or cloned to.
  3. Run `ruby –version`
    1. If you get the answer “1.8.7-p352”, congrats, go to 3 (argh, I used a goto!)
    2. If not, try setting your ruby to the system default.
      1. rvm users should run `rvm use system`,
      2. rbenv users can use `rbenv local system`.
    3. If you don’t see version 1.8.7-p352 now, we’ll install it. rvm users run `rvm install 1.8.7-p352`, wait for the compile to finish and then run `rvm use 1.8.7-p352`
  4. Now that’s sorted, lets build Command-T. First, cd into “ruby/command-t/”
  5. Run `ruby extconf.rb && make` to actually do the build
  6. Congrats, it should be built and working. Hit “<leader>t” in Vim and you should get the search box. Type in the name of your file and see if it completes!

I hope this helps, if not you can try loading my vim config and see if the Command-T I have built there works for you.

Composability is Crucial

In all technical work, I find there is an often overlooked principal which delivers a huge amount of value: Composablity.

In OO programming, this is represented by the core ideas of “loose coupling” and “highly-cohesion”. These principles drive us towards creating objects which can be reused and transposed easily- basically, we aim to make our objects composable in different circumstances.

In scripting and the whole-program level, composabily takes many forms. Adding lots of import/export options to your software enable users to involve it in their work more easily, but things really get interesting when you look at composability taken seriously.

One of the driving ideas for Unix/Linux was that of “small, sharp tools”, programs which do one job, very well. The result is almost magical: once you have learned a handful of the hundreds of commands, you can start piping the output of one into another. Suddenly you have a sort of “data manipulation Lego”- once you find the piece you are looking for, you can add it on to your others and quickly get some advanced behaviour.

Whatever I am building, I keep thinking about how my choices will affect it’s composability and found it a very useful tool. Hopefully it’s an idea that might help others too!

Edit: Sandi Metz gave a great talk which highlights the use of composition/collaboration to avoid an “Omega problems” and keep your projects fun to work on.