How Can Vim and Windows See Two Different Files that Have the Same Name in the Program Files Directory
I'm seeing a strange interaction between vim, the Cygwin tools, and Windows7. I don't think that it is a bug, but at the same time, I have no idea how to explain what I'm seeing.
I installed Vim (from vim.org, not the Cygwin vim) in:
"C:\Program Files (x86)\Vim".
I cd'd to this directory and edited my _vimrc file using vim itself.
vim _vimrc
I added some settings, wrote the file out, and exited.
I then copied the file to a different directory to create a backup of my changes.
copy _vimrc c:\tmp
That's when I noticed the issue. The copy of the file did not contain my changes. Much investigation followed. I will summarize the findings.
Within "C:\Program Files (x86)\Vim", I see my changes if I inspect the file with any of the following:
vim, cat, less
(Here, cat and less are the Cygwin versions.)
However, I do not see my changes If I inspect the file with any of the following:
notepad, type, more
(The commands type and more are standard Windows shell commands.)
To give you a flavor:
c:\Program Files (x86)\Vim>ls -l _vimrc
-rwx------+ 1 carlx Domain Users 936 Dec 23 21:15 _vimrc
c:\Program Files (x86)\Vim>dir _vimrc
Volume in drive C is OSDisk
Volume Serial Number is 6C86-85EB
Directory of c:\Program Files (x86)\Vim
06/28/2011 02:09 PM 901 _vimrc
1 File(s) 901 bytes
0 Dir(s) 95,964,721,152 bytes free
The Cygwin ls command shows a different file (different date and size) than the Windows dir command.
I thought that perhaps it was some sort of issue with the casing of the filename, but specifying _VIMRC versus _vimrc to any of these commands, makes no difference.
Can anyone explain what I'm seeing here?
As Raymond Chen and @kreemoweet pointed out above, this is caused by filesystem virtualization. To turn this off, you can use the Local Group Policy editor, gpedit.msc
. Type start gpedit.msc
into a command prompt and navigate to Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options. Scroll to the bottom of the right-hand window and double-click on User Account Control: Virtualize file and registry write failures to per-user locations
. Change the setting from Enabled to Disabled.