Sunday, January 15, 2012

Shared Common Vimrc

In my 'office' situation, I am the only Vim expert. The others use Vim, but they don't care to learn the arcane lore necessary to wear the Vimmer Hat, flash the Vi gang sign and wield a bitching vimrc menacingly.

So, it's up to me to craft a quality vimrc for all to use equally. The problem is... we're not all equal. Someone likes this colorscheme and others not so much. I play with various plugins and their settings, the others just have a few core plugins and get on with life. We needed a way to balance the two mutually exclusive desires of having a consistent, shared, quality vimrc and individuality.

So, I came up with a solution. I share the whole ~/.vim/ tree among the office workers. Inside ~/.vim/ we have:

  vimrc_common
  vimrc_fred_pre
  vimrc_fred_post
  vimrc_tom_pre
  vimrc_tom_post

And each user has the following link in their $HOME:

  ln -s ~/.vim/vimrc_common .vimrc

Special Source

The ~/.vim/vimrc_common looks like this:

  set nocompatible
  call pathogen#infect()
  filetype plugin indent on
  syntax on
  source $HOME/.vim/vimrc_${USER}_pre

  " lots of common settings and mappings

  source $HOME/.vim/vimrc_${USER}_post

Actually, I am lying a tiny bit... Raimondi & I roll our own version of pathogen which allows multiple bundle paths and provides a cool command interface to List, Enable, and Disable plugins. So the infect call in my vimrc_common file is actually:

  call pathogen#infect('bundle/shared', 'bundle/local', 'bundle/colours')

As you can see, we can each have a local pool of plugins as well as the shared common set. You can have as many as you want, and I just decided one day to separate the colours. That's what Raimondi's pathogen offers. :-) Apart from that, all true... Scout's honour.