Managing Vim Plugins Easily Using Git

Managing Vim plugins can quickly get messy. Fortunately, there are several solutions to this problem. My favorite one is Pathogen by Tim Pope. It makes it easy to install plugins in their own private directories and automatically load them. And combining it with Git will make your Vim configuration easily portable across computers.

Install Pathogen

So how do we set it up? First of all, prepare a Git repository for your Vim plugins:

$ git init .vim
$ mkdir .vim/bundle

Next, get Pathogen. To makes things easier, we will add it as Git submodule:

$ git submodule add https://github.com/tpope/vim-pathogen bundle/pathogen
$ ln -s autoload bundle/pathogen/autoload

Furthermore, to enable Pathogen, you must add the following lines to your .vimrc:

execute pathogen#infect() syntax on filetype plugin indent on

Managing Vim plugins

Now you can happily start adding other plugins as submodules. Here is an example using Vim Sensible:

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

In order to update them later, just run:

$ git submodule update --remote --merge

Finally, if you ever need to delete them later, follow these steps:

$ git submodule init bundle/vim-sensible
$ git rm bundle/vim-sensible
$ rm -Rf .git/modules/bundle/vim-airline
$ git commit

Synchronize everything

Just one thing is missing to make the setup perfect. Ideally, your vimrc would be stored along with the plugins. I prefer dotfiles for the job. For it is simple and ready to install using pip. So let’s do that:

$ sudo pip install dotfiles

Then create a folder for your Vim configuration (which you can use for other configurations as well):

$ git init Dotfiles

Finally, add the Vim configuration files:

$ dotfiles --add ~/.vimrc
$ dotfiles --add ~/.vim

Voilà. At last, you can keep the changes to your Vim settings and plugins safely versioned now. And to set them up on a new computer, you just need to clone the repository, install dotfiles and run:

$ dotfiles --sync

Can’t get easier than that. Now, head over to see some of my Vim tips.