How can I get gVim (Windows) to use "home\.vim" for my plugins?

Austin R picture Austin R · Nov 30, 2012 · Viewed 18k times · Source

I have a Desktop running Windows 7, and a Macbook Pro running Mountain Lion. I use gVim and MacVim respectively. I like to keep my plugins and settings synced between the machine, so I store them in my Google Drive, and I can always pull them from there.

On my Mac, I just have a .gvimrc file and a .vim folder in my home folder, and Vim loads all my plugins and settings properly.

On my Windows computer however, Vim WILL properly load settings from the .ggvimrc file in my home folder. But if I store plugins in "home.vim\plugin" Vim will NOT load them.

To get plugins/themes working on my Windows machine, I need to put them in "C:\Program Files (x86)\Vim\vimfiles\plugin"

I would like to be able to store everything in my "home.vim" folder on either machine, and have it work properly.

So is there any way to set this up on my Windows machine?

Thank you!

Answer

Ingo Karkat picture Ingo Karkat · Nov 30, 2012

As long as you keep your .vimrc in a default location (cp. :help vimrc), and only want to change the path to plugins, syntax files, etc., you can put the following into your .vimrc file:

if has('win32') || has('win64')
    set runtimepath=path/to/home.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,path/to/home.vim/after
endif

You didn't specify your exact path, so I used path/to/home.vim here; adapt to your system.


Your use case of synchronizing the configuration is quite common, what is unusual is that you seem to want to keep your .[g]vimrc in a default location, but only move the plugins etc. somewhere else. Typically, both .vimrc and the .vim/plugins subfolders are moved away, and people use symbolic links (created with mklink on Windows) to refer to them from their home directory.