Automatically loading Vim files from Dropbox folder

I have been a happy Dropbox user for a while now. I try to link whatever possible to it like:

  • Visual Studio settings
  • PowerShell modules
  • Resharper mounted live template file

Until today I was still copying my vimfiles back and forth though.

So I finally took the time to investigate how to point the vim runtimepath to a folder of my choice.

Turns out there are two ways to do this:

  1. Point the vim runtime path to a folder in your dropbox
  2. Create a link from your local vimfiles folder to the vimfiles folder in your dropbox

Point the vim runtime path to a folder in your dropbox

In this case vim itself (‘:help runtimepath’) was more helpful than stackoverflow and google.

This stackoverflow answer maybe useful to others, but in my case I never could get the printf() statemtent to work and I also would like to start vim without specifying the path every time.

As I said, the help helped (npi) and after a bit of experimentation I came up with this solution.

I added

set runtimepath=~/Dropbox/Settings/vimfiles,$VIM,$VIMRUNTIME

to my .vimrc file.

Note that for Windows the dropbox folder is called ‘My Dropbox’ and therefore you need to escape the space like so:

set runtimepath=~/Dropboxes/Gmail/My\ Dropbox/Settings/vimfiles,$VIM,$VIMRUNTIME

Now I could remove my .vim folder (vimfiles on Windows ) from my HOME directory and am picking up all my plugins, syntax highlighters, etc.  directly from the given vimfiles folder inside my Dropbox.

Only the .vimrc file has to stay were it is and will have to be synchronized among my computers since something has to do the pointing.

Create a link from your usual vimfiles folder to the vimfiles folder in your dropbox

I found a great explanation on how to do this on different operating systems.

Here is an example on how to do this on Windows:

  1. Make sure that all your vimfiles have been copied to your Dropbox folder.
  2. Remove the vimfiles in you HOME directory.
  3. Launch cmd.exe and use mklink to create a link from ~/vimfiles to the vimfiles in your dropbox e.g.:
    mklink /D "c:\Users\yourusername\vimfiles" "C:\Users\yourusername\My Dropbox\Settings\vimfiles"
  4. Optionally do the same for your .vimrc file (I actually link it to a window specific one, because I use a different font for each OS):
    mklink "c:\Users\yourusername\.vimrc" "C:\Users\yourusername\My Dropbox\Settings\.vimrc_windows"

    In this case you need to make sure to not directly edit the local .vimrc as this will overwrite the link you created. Instead edit the .vimrc inside your Dropbox folder.

Both solutions allow me to extend my vim, for all my machines in one shot.

  1. #1 by Benjamin Miller on January 3, 2014 - 6:05 pm

    Awesome, this is exactly what I was looking for!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: