Symlink to .vimrc on windows makes file readonly upon write. Why?

6

I've put my .vimrc file in a central location (dropbox folder, also a hg repository).

Under Windows 7, I've symlinked to it from my home folder (strangely enough I had to do it as an administrator, otherwise I got 'no permission'):

C:\users\Me>mklink .vimrc C:\users\me\dropbox\dotfiles\.vimrc

After fixing an overwrite issue by using set backupcopy=yes (found here: gVIM breaks symlinks on windows?), I have another issue. When I save the modified file, the real .vimrc (in my dropbox/dotfiles folder) gets a read-only flag as soon as I save it (using :w).

Why is this? How can I prevent this?

Rabarberski

Posted 2012-08-31T09:54:45.217

Reputation: 7 494

3I can propose another way of solving symlink issue, which I use on Windows XP machines. Create _vimrc with one line source /path/to/real/vimrc and update $MYVIMRC variable in your real vimrc file, e.g. let $MYVIMRC='/path/to/real/vimrc'. Maybe this will solve your current issue. – xaizek – 2012-08-31T10:07:20.443

@xaizek: I've adopted your solution. No more annoying windows symlink stuff... – Rabarberski – 2012-08-31T13:30:59.033

OK, just did it. I wasn't sure whether it's the right thing to do, since my comment doesn't really answer your question. – xaizek – 2012-11-09T19:20:07.280

Answers

11

I can propose another way of solving symlink issue, which I use on Windows XP machines or on Windows 7 without administrative rights.

Create _vimrc file with one line

source /path/to/real/vimrc

and update $MYVIMRC variable in your real vimrc file, e.g.

let $MYVIMRC='/path/to/real/vimrc'

Changing value of $MYVIMRC is useful for referring to correct vimrc file (for example in autocommands that reread it) on different systems.

xaizek

Posted 2012-08-31T09:54:45.217

Reputation: 891