As a software engineer I often prefer to use Vim with an appropriate set of plug-ins for my daily work. Vim is a great editor to get work done, especially when making use of the available plug-ins and the power of personal settings in my ‘.vimrc’ file. But to maintain those plug-ins and ‘.vimrc’ file on a local system can become very cumbersome. It becomes even more cumbersome when you work on multiple machines. Then not only plug-in maintenance is cumbersome, but the fact that you have to install them again every time becomes annoying as well.

In this article I want to show how I am able to make use of a single installation of my plug-ins and ‘.vimrc’ using the power of Dropbox and Vundle.

Although Pathogen seems to be the more popular solution I decided to use Vundle as this enables me to maintain my plug-ins from Vim. The article will assume that you are using Linux. Later instalments will show how to use the set up on multiple platforms.

Create a directory structure in your Dropbox directory

From a terminal create the initial directory structure using the command shown below. It is assumes that your Dropbox folder is named ‘Dropbox’ and is in your HOME directory.

mkdir -p ~/Dropbox/vim/bundle

This creates the directory in which all plug-ins will be installed.

Install Vundle

Go to the newly created directory:

cd ~/Dropbox/vim/bundle

Now Vundle can be installed. It is assumed that Git is already available on your system.

git clone https://github.com/gmarik/vundle.git

Create a ‘vimrc’ file

As I want to use the same vimrc on multiple platforms a generic file will be created that will later be included from a platform specific ‘vimrc’. Go to the vim directory:

cd ~/Dropbox/vim

And create a file named ‘vimrc’ (no leading dot!) with the following contents:

set nocompatible " must be first line
filetype off     " required!
 
" Point Vundle to the directory holding the plug-ins. The variable 'g:bundle_dir_from_vimrc'
" should contain the full path and is set from your platform specific vimrc file.
call vundle#rc(g:bundle_dir_from_vimrc)
 
Bundle 'gmarik/vundle'
 
filetype plugin indent on " required!

The strange line starting with ‘Bundle’ is Vundle’s way of knowing which plug-ins are available. By including Vundle itself as a Vundle maintained plug-in it becomes possible to maintain Vundle using Vundle itself.

Create a platform specific ‘vimrc’ loader

As runtime paths and ‘vimrc’ names can differ on platforms a ‘vimrc’ loader for each platform needs to be created. Start of by creating a directory structure in the Vim Dropbox folder where the ‘vimrc’ will be stored:

mkdir -p ~/Dropbox/vim/platforms/linux

Now create a ‘.vimrc’ file (using your favourite editor of course :) ) with the following contents:

" Add the Vim folder in the Dropbox folder to the runtime path.
" This has the advantage that all Vim settings (such as spell files and colour
" themes) not maintained by Vundle can at least be kept in, and used from
" Dropbox
set runtimepath+=~/Dropbox/vim
 
" Point Vim to the Vundle script
set runtimepath+=~/Dropbox/vim/bundle/vundle/
 
" Set the path to the plug-in directory. Used when Vundle is initialised in
" 'vimrc'
let g:bundle_dir_from_vimrc="~/Dropbox/vim/bundle"
 
" Call the generic 'vimrc'
source ~/Dropbox/vim/vimrc

Create a symbolic link to the ‘vimrc’ loader in your HOME directory:

cd; ln -s ~/Dropbox/vim/platforms/linux/.vimrc

This should now enable Vundle. Test by starting Vim and issuing the following command:

:BundleList

Your vim should now look something like this:

Vim after initial Vundle installation

To test drive even further we are going to install one of my favourite plug-ins: a.vim. Edit the generic ‘vimrc’ file and add the following line below the bundle entry for Vundle itself:

Bundle 'a.vim'

Save, close Vim, start a new Vim and issue the following command:

:BundleInstall

The next time Vim is started the plug-in should be fully functional.

Adding other Vim settings

Of course I also want my specific colour themes, spell files, etc. centrally available. The necessary work has already been done by setting the runtime paths in the ‘vimrc’ loader. The directory ‘~/Dropbox/vim’ can now be used to install colour themes in the ‘colors’ subdirectory, spell files in the ‘spell’ subdirectory etc.

Hopefully you find this set up as useful as I do. If you have any questions regarding the set up or if you have any other remarks then please let me know.