DotNetSurfers

Latish Sehgal's Blog

Using the Same Vimrc With Multiple Operating Systems

I use Vim a lot. I spend most of my (coding) day inside vim in one form or another. I use terminal Vim on Windows, Mac and Ubuntu depending on the project I am working on. In visual studio, I use the excellent VsVim plugin. While browsing the web, I use Chromium plugin in Chrome. I am writing this blog post in Vim on my Ubuntu VM.

Even after having used it for a couple of years, I didn’t have a standard vimrc configuration across all my platforms. I was using Janus in a couple of places, and spf13 in others. I also had random tweaks all over the place. This week I decided to rebuild my vimrc and share it on all 3 platforms using Dropbox. It turned out to be much more simpler than I thought it would be. I started with the spf13 vimrc, and took out the stuff I didn’t understand or need. It uses Vundle for plugin management and that works great for me. I tweaked around with the vimrc settings and the plugins according to my preferences and then put them in Dropbox. After that, all it took was creating symbolic links on all 3 platforms to the Dropbox location and I had a consistent Vim setup. Roughly, the steps I took were:

  • Moved all old vim config files in a temporary backup folder.
  • I started with my Mac setup. I put the vimrc and vimrc.bundles files in Dropbox (in my case, the path to these files was ~/Dropbox/dotfiles/). I also created an empty .vim folder in the same directory.
  • Created symbolic link for .vimrc, .vimrc.bundles files and the .vim folder in my root folder that point to the Dropbox location.
      ln -s ~/Dropbox/dotfiles/.vimrc ~/.vimrc
      ln -s ~/Dropbox/dotfiles/.vimrc.bundles ~/.vimrc.bundles
      ln -s ~/Dropbox/dotfiles/.vim ~/.vim
    
  • Installed vundle
      git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
    
  • Installed the bundles configured in .vimrc.bundles by launching vim and running the :BundleInstall command. Verified that everything works as expected.
  • Then on my Windows and Ubuntu VMs, I just had to create the symbolic links. On windows, the file name needs to be _vimrc, and the order of arguments is reversed for creating links.
    • On Windows
        mklink  C:\Users\LatishSehgal\_vimrc C:\Dropbox\dotfiles\.vimrc
        mklink  C:\Users\LatishSehgal\.vimrc.bundles C:\Dropbox\dotfiles\.vimrc.bundles
        mklink  C:\Users\LatishSehgal\.vim C:\Dropbox\dotfiles\.vim
      
    • On Ubuntu
        ln -s ~/Dropbox/dotfiles/.vimrc ./\.vimrc
        ln -s ~/Dropbox/dotfiles/.vimrc.bundles ./\.vimrc.bundles
        ln -s ~/Dropbox/dotfiles/.vim ./\.vim
      

If you want to check out my vimrc for reference, it is on Github.

P.S If you are interested in tools that make you more productive, and work with Sql Server Management Studio, you should check out SqlSmash.

Comments