Oct 17, 2014

Tinkering. Improving. Breaking. Fixing.

I'm always changing my settings in Vim and I would like them to be consistent between my computers, Windows and Mac. I'm a huge fan of Vundle, a Vim plugin manager that is super simple and easy to use. So I figured why not take advantage of Vundle to keep my Vim settings synced, backed up, and historical.

The Solution

The basic idea is to sync Vim settings in a git repository using Vundle. My solution is built with my settings embedded for others to use or fork and customize. Once setup, any customizations and updates are synced via Vundle. In addition, as people fork the repo we can all take from each other and have a nice little place to see what others are doing. The solution I came up with is vim-settings.


Vundle is easy to setup with a simple git clone command and a change to the ol' vimrc. Vundle allows you to easily download Vim plugins by referencing them in a vimrc and running :PluginInstall. Plugins can then be updated with :PluginUpdate and removed with :PluginClean after removing from the vimrc. Then to make updates, since Vundle using git, it's easy to edit the synced Vim settings and push changes via git.

The New Vimrc

When looking for a solution I know I wanted the setup to be fast and permanent. I wanted to setup everything once and never touch it again. The first step was to make the old vimrc act as starter kit for the new Vim settings vim-settings.vim. The vimrc references Vundle and the new settings included in vim-settings synced via Vundle. Note I set the new Vim settings file to a variable so that you can easily open the new settings file with :e $VIMSETTINGS. You can make changes to this file and push them to the repository to be synced with other computers.

" Vundle setup
exec ":set runtimepath+=" . vimsettings_bundlepath . "/vundle/"
call vundle#begin(vimsettings_bundlepath)
Plugin 'gmarik/vundle'

" Include vim-settings
Plugin vimsettings_username . '/vim-settings'

" Load vim-settings.vim and tie it to $VIMSETTINGS
let $VIMSETTINGS = vimsettings_bundlepath . "/vim-settings/vim-settings.vim"
if filereadable(glob($VIMSETTINGS))
  exec ":so " . $VIMSETTINGS
  call vundle#end()

Also in the vimrc starter kit I include a helper function for the initial setup. It simply runs Vundle install twice so that vim-settings is downloaded, then any plugins included in the new settings are then downloaded.

" vim-settings init helper
if exists("vimsettings_loaded")
let vimsettings_loaded = 1
function! VimSettingsInit()
  :so $MYVIMRC
  :so $MYVIMRC
command! -bar -nargs=0 VimSettingsInit call VimSettingsInit()

That Was Easy

Yep. My solution is pretty flippin simple. So get at it. Fork this bad boy and keep your Vim settings on track with Vundle. Step-by-step installation instructions are in the repository's README.