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

7

20

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!

Planar answered 30/11, 2012 at 18:58 Comment(0)
P
1

I was unable to implement either of your suggestions for some reason.

I ended up finally solving this by by creating softlinks to my Google Drive folder on all machine. Now if I edit my .vimrc or .vim folder in my Google Drive folder, it's reflected on all machines instantly. It's great!

Planar answered 1/12, 2012 at 17:51 Comment(0)
S
21

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.

Scalpel answered 30/11, 2012 at 19:31 Comment(1)
This reference to symbolic links was what helped me and I see it as an answer below: symlink .vim to vimfilesTound
D
6

Somewhere at the beginning of your .vimrc (inside a if has('win32') || has('win64') if your files have to run on other platforms)

set runtimepath-=~/vimfiles
set runtimepath^=~/.vim
set runtimepath-=~/vimfiles/after
set runtimepath+=~/.vim/after
Davidadavidde answered 6/4, 2017 at 3:36 Comment(1)
-= removes from the variable, ^= prepends to the variable, += appends to the variable, all with proper handling of commasDisperse
Q
3

On Windows 7, you must put your plugins and colorschemes in:

C:\Users\username\_vim\

and your settings in:

C:\Users\username\_vimrc
Quotable answered 30/11, 2012 at 19:32 Comment(0)
B
3

First I put the contents ~/vimfiles into ~/.vim.

Then I added this to my vimrc:

let &runtimepath.=',$HOME/.vim'
Burress answered 26/3, 2014 at 14:26 Comment(1)
Your after files won't work (~/.vim/after). See Ingo's answer.Afro
B
3

On Windows 10, the vim directory is located at %USERPROFILE\vimfiles, you may link it to any other directory through the mklink command.

Bocock answered 23/9, 2017 at 2:14 Comment(0)
O
3

On Windows I don't use %USERPROFILE% to store .vimrc, instead, I create an environment variable %HOME% pointing to my custom directory, and I have %HOME%/.vimrc and %HOME%/.vim/ there, using .vim/ makes sure the "vim" from Windows git installation can use them directly.

The Windows VIM has a default runtime path entry of ~/vimfiles, with ~ corresponds to %HOME%, so I create a directory symbolic link as follows:

cd /d %HOME% mklink /j /d .vim vimfiles

Then all both the .vimrc and .vim/ in my custom directory are working in different environments, without if has("win32") stuff in your .vimrc for this purpose.

Osteopathy answered 19/7, 2021 at 2:4 Comment(0)
P
1

I was unable to implement either of your suggestions for some reason.

I ended up finally solving this by by creating softlinks to my Google Drive folder on all machine. Now if I edit my .vimrc or .vim folder in my Google Drive folder, it's reflected on all machines instantly. It's great!

Planar answered 1/12, 2012 at 17:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.