Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to keep my gVIM config in centralized place. For this, i have done

mklink c:\users\me\.vimrc c:\users\me\configs\_vimrc

That works fine until i change $MYVIMRC inside VIM. This instantly breaks symlink (c:\users\me.vimrc stop being a symlink and became ordinary file). Is it any way to fix this trange behavior? OS is Windows Vista with latest updates. gVIM is 7.2 from official site.

share|improve this question
up vote 3 down vote accepted

Vim is supposed to handle this correctly by default. (:help backupcopy)

By default, on non-unix platforms, backupcopy is set to "auto". It will normally rename the file and write a new changed file when you save, but should modify the original file if the original file is a link or has a resource fork, etc.

Several possibilities:

  1. Your version of vim does not recognize the file is a symlink.
  2. You've set backupcopy or a related variable (breaksymlink?) to override default behavior.

I'd be surprised if it's 1, since you're dealing with a recent version of vim. Does this happen if you have an empty .vimrc?

share|improve this answer
You are right, setting 'set backupcopy=yes' fixes problem on Vista+. Thanks! – Eye of Hell Oct 9 '09 at 7:08
Was backupcopy set to no before? auto is probably a better setting than yes, assuming it works in this case. – Captain Segfault Oct 9 '09 at 22:38


mklink /J c:\users\me c:\users\me\configs

This will create a hardlink directory junction between c:\users\me and c:\users\me\configs that vista will respect when you rewrite you vimrc.

share|improve this answer
Have you tried this? The equivalent, in linux at least, would not work, because vim writes out a new file and copies it over when you save. – Captain Segfault Oct 8 '09 at 23:20
Oh, it's a directory link and not a file link, nevermind my previous comment. – Captain Segfault Oct 8 '09 at 23:23
Linking entire HOME folder is kind of... painful :) – Eye of Hell Oct 9 '09 at 4:11
Consider it to be the... Spleen of Hell ;-) – DaveParillo Oct 10 '09 at 0:06

The user xaizek suggested an workaround in the comments of a related question I asked: Symlink to .vimrc on windows makes file readonly upon write. Why?. I've adopted his solution, but made the $MYVIMRC assignment conditional because I use both Windows and OSX systems:

So, in my Windows ~/.vimrc file I have:

source /path/to/shared/vimrc

Then, in the shared .vimrc file I have:

if has("win32")
    let $MYVIMRC='~/path/to/shared/.vimrc'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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