gVIM breaks symlinks on windows?

7

2

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.

grigoryvp

Posted 2009-10-08T16:45:53.470

Reputation: 957

Answers

3

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?

Captain Segfault

Posted 2009-10-08T16:45:53.470

Reputation: 1 224

You are right, setting 'set backupcopy=yes' fixes problem on Vista+. Thanks! – grigoryvp – 2009-10-09T07:08:59.857

Was backupcopy set to no before? auto is probably a better setting than yes, assuming it works in this case. – Captain Segfault – 2009-10-09T22:38:18.837

1

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'
endif

Rabarberski

Posted 2009-10-08T16:45:53.470

Reputation: 7 494

1

Try

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.

DaveParillo

Posted 2009-10-08T16:45:53.470

Reputation: 13 402

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 – 2009-10-08T23:20:16.327

Oh, it's a directory link and not a file link, nevermind my previous comment. – Captain Segfault – 2009-10-08T23:23:38.067

Linking entire HOME folder is kind of... painful :) – grigoryvp – 2009-10-09T04:11:14.893

Consider it to be the... Spleen of Hell ;-) – DaveParillo – 2009-10-10T00:06:34.340