I am trying to create a (git) repository for my vim files. Now, I am already struggling as to what directory I would store my files under. As far as I can see there is either %HOME% or %VIM%, right? Naturally, I feel more inclined to use %VIM%. So I go

set VIM=x:\path\to\repo

cd %VIM%

notepad vimrc

to create a basic vimrc file in my repo. The vimrc also contains syntax enable. Now, when I start gvim and the startup process reaches the syntax enable line, it gives an error message:

Error detected while processing x:\path\to\repo\vimrc
line 86
E484: Can't open file x:\path\to\repo\syntax\syntax.vim

This seems to be because vim automatically sets $VIMRUNTIME to the value of $VIM if $VIM is set. This is of course not what I want, since I was happy with vim's default determining of $VIMRUNTIME at startup. Neither do I want to globally set %VIMRUNTIME% as I don't want to change it if I install a newer vim version.

So, what is the canonical way to keep my personal vim files in a repository?

  • possible duplicate of GitHub for .vimrc and plugins
    – Tom
    Commented Jul 24, 2015 at 7:35
  • Perhaps you want to use forward slashes? i.e. set VIM=x:/path/to/repo. I don't have a Windows machine to test, but all the docs use forwards slashes. Commented Jul 24, 2015 at 9:08
  • Don't manually set the VIM environment variable. $VIM and $VIMRUNTIME are automatically set by Vim when it runs. You should prefer to use $HOME since that is your personal config area where as $VIM is a system directory, which you may not even have write access to.
    – jamessan
    Commented Jul 24, 2015 at 14:20

3 Answers 3


Since 7.4, all your configuration files (even your vimrc) are expected to be in this directory:


But the name and location of that directory only matter to Vim. From Git's point of view, that directory could as well be /etc/foo/bar/ without any impact whatsoever.


  1. put your vimrc and all your third-party scripts in %userprofile%\vimfiles\,
  2. put that directory under version control.

When you need to clone your repo on a unix-like system you do:

$ git clone <remote url> ~/.vim

or, in git bash on Windows:

$ git clone <remote url> $HOME/vimfiles

No need to mess with environment variables.

  • Minor nitpick: %HOMEDRIVE%%HOMEPATH% is the location checked first, and I think %USERPROFILE% was only added as a fallback in patch 8.0.1012. I don't know Windows well enough to say whether that means that - as of that patch - $HOME will always end up set to %USERPROFILE% in practice?
    – Rich
    Commented Mar 13, 2018 at 15:20

I have a repository called rc which contains a install.sh script and all my runtime configurations. My workflow is like so:

  • On a machine, hack ~/.vimrc till I am happy with it.
  • Copy ~/.vimrc to rc/vimrc.
  • Add, commit with a useful message, and push.
  • On a different machine: fetch+merge rc.
  • Run install.sh which takes a backup of the current file and copies the repository one over the current one.

Clearly this works on *nix and not on Windows. However, the method could be easily adapted. How to do this is left as an exercise for the reader1.

1. Mostly because I have no idea how to it myself!

  • 2
    You might be better off just putting your vimrc in the rc folder and using a symlink for ~/.vimrc, like so: ln -s ~/rc/vimrc ~/.vimrc. That way, you don't have to worry about copying it back and forth from ~ and rc.
    – 8bittree
    Commented Jul 31, 2015 at 23:22
  • @8bittree: That ... That would be indeed better. Commented Aug 3, 2015 at 6:50
  • @8bittree Will making a hard link make a difference?
    – MaNyYaCk
    Commented Dec 3, 2018 at 12:28
  • @MaNyYaCk Please use dotbot instead. Much better tool. Commented Dec 3, 2018 at 13:15
  • @MaNyYaCk I would expect a hard link to work fine, but, as I don't find myself using them very often, it's entirely possibly that they have some behavioral quirk that I'm unaware of that might cause problems.
    – 8bittree
    Commented Dec 3, 2018 at 14:06

I put all of my plugins right into the hierarchy, I see the benefits of the various plugin managers but they don't do things that I want... I also locate my Vim configuration hierarchy "remote" from my user directory because it is shared between operating systems (via Bootcamp for instance) and across machines and even in some cases across the network.

On my current machine this is my .vimrc:

set runtimepath^=~/Documents/dotfiles/vim
runtime vimrc

On a different machine, running Windows, it's similar:

set runtimepath^=C:/dotfiles/vim
runtime vimrc

And my .gvimrc in both cases just uses runtime gvimrc. If this directory is shared on the network I can also happily use (via batch file and to a shared location for the vim runtime too)

gvim -u \\my_pc\dotfiles\vim\vimrc -U \\my_pc\dotfiles\vim\gvimrc

All of this is in source control of course but if I'm just remoting into a computer sometimes it's easier just to load the config off of my host directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.