This is a step by step tutorial on how to organize your vim config files using
git, pathogen, and git submodules. This tutorial assumes that you are familiar
with git basics, but you don’t really need to understand every step in order to
follow it. For simplicity, only
.vim directory is a repository in this
example. You may want to have all your dotfiles under version control and use a
script to symlink files to the home directory. For example see
Let’s assume your
.vim directory is a mess and is not under revision control.
Let’s initialize a repository.
cd ~/.vim git init git remote add origin firstname.lastname@example.org:user/project.git
Now let’s create
.vim/bundle directory and clone
pathogen plugin as a
mkdir bundle cd bundle git submodule add email@example.com:tpope/vim-pathogen.git bundle/vim-pathogen
Pre-pend the following code to your
~/.vimrc to load pathogen from
runtime bundle/vim-pathogen/autoload/pathogen.vim execute pathogen#infect()
Let’s add some more plugins as git submodules, for example:
git submodule add firstname.lastname@example.org:Lokaltog/vim-easymotion.git bundle/vim-easymotion
Now we can add and commit everything and push it to a repository.
git add . git commit -m "Use pathogen to keep track of vim plugins" git push origin master
Assuming that your repository is located at
cd ~ git clone email@example.com:user/project.git .vim
And you are done, all plugins are downloaded from their repositories now.
Git submodules keep track of specific commits and are not being automatically updated when target repositories have new commits. In order to update plugins you have:
cd ~/.vim git submodule foreach git pull git add bundle git commit -m "Updated all the plugins in a bundle" git push origin master
You probably want to make sure that new versions of plugins are compatible with each other before committing, however.