Skip to main content
1 of 6

Vim VM-created .swp file exists and Vim ignores it

Can a Vim guru explain this behavior? It may require knowledge of Vim internals because the behavior is different under different operating systems.

I have a file open in Vim inside a VM (virtual machine) and I then try to open the file on Windows, and I do not get that warning that goes "Swap file blah.swp already exists!" I want that warning because that is the only way I can find out I am already editing the file somewhere else, like in this case, in the VM!

So for some reason the warning does not happen when a VM is in between, and whether I edit the file on Windows first and then use the VM, or I edit the file in the Linux VM and then open the file in Vim on Windows, it's the same result, no warning. So no warning on Windows if the file is open in the VM and no warning in the Linux VM if the file is open on Windows. And in both cases vim creates a .swo file silently. On the other hand, if the file is opened a second time on the VM while being already open on the VM, I do get the warning, and same thing on Windows.

Reading the documentation at the following in Vim does not give anything informative:

:help recovery

The above just discusses why the .swp file exists, and discusses how Vim can recover lost information etc. It doesn't get into any details like what is causing me this problem.

Any way to ensure I always get this warning?