About     Projects     GitHub     Now     Else

Syncing Vim Across Different Environments

One of the great things about Vim is that it requires very little customization. For the things that you do want to customize, however, it’s really good when you can keep everything in sync across your various environments.

vimrc

Putting Your Vim Configuration in Version Control

My first suggestion is to store your .vimrc configuration file in your ~/.vim folder so that you can easily keep everything in version control. By default, Vim looks for .vimrc in your home directory, so, in order for Vim to work properly, you will need to create a symbolic link called .vimrc in your home directory. This can be accomplished with the command

$ ln -s ~/.vim/.vimrc ~/.vimrc

Managing Plugins with Vundle

Now that your Vim configuration is in version control, managing your plugins can be made easy with Vundle. I use Vundle instead of Pathogen because running commands like “execute pathogen#infect()” might make the security team where I work nervous, and I want to use the same configuration at work as I do at home, but I’m sure Pathogen could work just as well.

Here is a snippet from my vim configuration:

" set the runtime path to include Vundle and initialize

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins

Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
" All of your Plugins must be added before the following line

call vundle#end()            " required

With Vundle, you can easily manage all of your plugins in one convenient location, and, if you add a new plugin in one environment, when you pull your .vimrc into your other environments and run

:PluginInstall

in the ex line, the plugins you added in your other environments will be automatically installed on your current environment.