Pathogenize your VIMPublished on Oct 18, 2012

We're going to take a look how to create your own .vim config in a matter of minutes. There are many ways to do this. First one is pathogen, which I'm going to describe in this article, and then there's also janus and vundle.

I prefer pathogen because it's dead simple, you just need two lines in your .vimrc. But let's first do some initial setup:

$ take .vim   # if you're using bash, just do mkdir & cd
$ touch vimrc
$ ln -s ~/.vim/vimrc ~/.vimrc
$ git init
$ git commit -m "Initial commit"

Now you're ready to add pathogen to the mix.

call pathogen#runtime_append_all_bundles()
call pathogen#helptags()

and add pathogen itself to ~/.vim/autoload

$ mkdir -p ~/.vim/autoload
$ curl -Sso ~/.vim/autoload/pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

That's it, you're done! Let's just commit the changes.

$ git add vimrc
$ git commit -m "Add pathogen config to .vimrc"

Adding a plugin

Now let's talk about how we add a plugin. One of my favorites is rails.vim by Tim Pope, so let's add that.

Pathogen uses git submodules for plugins, so it's as easy as

$ git submodule add https://github.com/tpope/vim-rails.git bundle/rails

You can chose whatever name you want, just make sure it ends up in the bundle directory. Also let's make sure we commit the addition.

$ git commit -m "Add rails.vim"

and the next time you run vim, you'll have the plugin automatically loaded.

Cloning the repo on a new machine

When you want to clone the repository on a different machine, you also need to initialize the submodules. Let's see how that would work.

$ git clone https://github.com/you/dotvim.git ~/.vim
$ ln -s ~/.vim/vimrc ~/.vimrc
$ cd ~/.vim
$ git submodule init
$ git submodule update

Removing a plugin

But what if you decide you don't need a plugin anymore? You're going to need to edit .gitmodules and .git/config and remove the submodule from both of the files.

After that just do rm -rf bundle/foo and commit the changes.

Written by Jakub Arnold of sensible.io.

Are you having trouble with JavaScript errors in production?

We are building a tool to solve the problem once and for all. It's called Trackets and it's really awesome.