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:

user@computer:~$ git init .vim
user@computer:~$ mkdir .vim/bundle

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

user@computer:~/.vim$ git submodule add https://github.com/tpope/vim-pathogen bundle/pathogen
user@computer:~/.vim$ 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:

user@computer:~/.vim$ git submodule add https://github.com/tpope/vim-sensible bundle/vim-sensible

In order to update them later, just run:

user@computer:~/.vim$ git submodule update –remote –merge

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

user@computer:~/.vim$ git submodule deinit bundle/vim-sensible
user@computer:~/.vim$ git rm bundle/vim-sensible
user@computer:~/.vim$ rm -Rf .git/modules/bundle/vim-airline
user@computer:~/.vim$ 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:

user@computer$ sudo pip install dotfiles

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

user@computer:~$ git init Dotfiles

Finally, add the Vim configuration files:

user@computer:~/Dotfiles$ dotfiles --add ~/.vimrc
user@computer:~/Dotfiles$ 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:

user@computer:~/Dotfiles$ dotfiles --sync

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

One thought on “Managing Vim Plugins Easily Using Git

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.