Please note: this blog has been migrated to a new location at https://jakesgordon.com. All new writing will be published over there, existing content has been left here for reference, but will no longer be updated (as of Nov 2023)

My favorite Vim plugins

Sun, Feb 20, 2011
Embracing Vim

Once you get comfortable with Vim’s basic commands and editing capabilities, you will want to start customizing your install. The 2 most common approaches are:

I will talk about my .vimrc in a future post, for now lets take a look at the plugins I found most useful.

Most vim plugins can be found on the official site but its not the most user friendly site for finding the best plugins. You will probably want to look around for posts by other programmers and see what they are using. Vim is a well established and highly customizable editor, and as such, many quality plugins have been developed over its lifetime. When you search online you will find that the same plugins are mentioned time and time again.

Installing plugins is done in 1 of 3 ways.

The website or help file for each plugin usually indicates which install mechanism to use, and each of the 3 ways are fairly easy.

As I spent my first few weeks with Vim I went on a little bit of a plugin spending spree, trying out lots of scripts I thought might be useful to me, but in practice only a handful ended up getting repeated use. I expect that list to change as I use Vim more and more for real programming and learn what is important and what is irrelevant.

The 3 plugins I find myself using the most are commandt, bufexplorer and ack:

Command-T

After spending many years using the file open dialog in Visual Studio or UltraEdit, I can’t help be a little jealous of TextMate users who get to open files using fuzzy matching with Command-T. So now that I am switching to Vim I finally get to open my files efficiently as well with this plugin, that I have mapped to <C-t>.

Note that while the install of this plugin is a simple vimball, it has some requirements that are tricky to get correct. First, you need a version of Vim that is built with Ruby support enabled, second you need to have the same version of ruby available that was used to build vim (1.8.7), and finally you need a C compiler to build the ruby extension used to make this plugin fast and efficient.

Here are the steps I took to install…

Check to see that my version of vim (debian vim-gnome) has ruby enabled:

vim --version | grep ruby
 ... +ruby ...
 ... -lruby1.8 ...

I work with ruby on my projects, but most of them have moved on to ruby1.9, so I need to install ruby1.8 and setup debian alternatives to be able to switch between the 2 versions.

sudo apt install ruby1.8 ruby1.8-dev rdoc1.8 ri1.8
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.8 400 \  
                         --slave   /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.8.1.gz \  
                         --slave   /usr/bin/ri ri /usr/bin/ri1.8 \  
                         --slave   /usr/bin/irb irb /usr/bin/irb1.8 \  
                         --slave   /usr/bin/rdoc rdoc /usr/bin/rdoc1.8
sudo update-alternatives --config ruby
sudo ruby --version

NOTE: I like to use the packaged debian versions of ruby. If you prefer to use RVM then your steps to install 1.8 and 1.9 side by side will differ.

Install the plugin:

vim command-t.vba
:source %
:q

Compile the C ruby extension:

sudo update-alternatives --config ruby        # ensure 1.8 is current ruby version
cd ~/.vim/ruby/command-t
ruby extconf.rb
make

Its the trickiest vim plugin to install, but its well worth it, giving you instant access to your project’s files if you have a rough idea of the name or path.

BufExplorer

As soon as you start opening multiple files you have to deal with managing those buffers, and this plugin makes life much easier than using raw Vim commands. Install the plugin by unzipping into your ~/.vim directory, then map an appropriate key, e.g:

map <C-b> :BufExplorer<CR>

… and now you can use that key to quickly list all your open buffers and switch between them. Easy and useful. Nice!

Ack

The absolute, most important tool in a programmers arsenal is the ability to efficiently find what you need amongst hundreds of files. We talk about grep as the tool that does that, but ack is a better grep designed for programmers, it has some knowledge about the types of files and knows to ignore things like .svn folders and temporary files.

The ack.vim plugin gives you an :Ack command within Vim that will run ack in the shell then present the results in a quickfix pane that can be used to quickly navigate to each line that contains your match.

To install ack in ubuntu:

sudo apt install ack-grep
sudo ln -s /usr/bin/ack-grep /usr/local/bin/ack

Then follow the official instructions to install the ack.vim plugin.

Other Plugins

Beyond that core, these are the other plugins that I use:

And here are a few that I thought would be great, but I just never ended up using:

Finally, here are some that I want to use, but have not yet got around to trying: