GVim runs very slowly when editing files on a windows share

Swap file has nothing to do with it. I have my swap file local and still have the problem. I use Process Monitor from SysInternals.com and it revealed bad behavior when attempting to open "\server\TestTool\foo\ReadMe.TXT"

It first attempts a CreateFile (aka, Directory open) on "\serve\". Notice the last character is missing. This will cause 4 seconds to time out with "OBJECT PATH INVALID".

Then it tries CreateFile on "\server\TestToo\". Server name is correct by the last letter of "TestTool" is clipped. Again, a 3 second time out with "BAD NETWORK NAME".

Finally it gets it right and calls CreateFile on "\server\TestTool\" which works right away. Then CreateFile on "\server\TestTool\foo" which works right away. Then CreateFile on "\server\TestTool\foo\ReadMe.TXT" which works right away.

WHY is it trying bad names for the server and the root directory??? What madness is this?


I fixed this issue after setting HOME path by force in advanced system settings. (Your current HOME path would be a network directory.)

Control Panel > All Control Panel Items > System > Advanced system settings > Environment variables

Press "New..."

Variable name: HOME

Variable value: c:\Home\ **<-- Type your home directory**


There are a few factors which may affect this.

First, make sure you have Vim setup to prefer storing the swapfile locally. If your $HOME is on a local drive, I tend to put this in my vimrc (which will either be at $HOME\_vimrc or $VIM\_vimrc). Make sure you create that directory, otherwise Vim will continue to use one of the other directories in the list.

set directory^=$HOME/tmp

This prepends the $HOME/tmp directory to the start of the list that Vim checks for where to place swapfiles.

Second, do the same for the backup file that Vim creates. Same situation as above but the option you'll be changing is backupdir instead of directory.

Third, make sure you disable the matchparen plugin. This plugin is new to Vim 7, so you may be used to using an older version of Vim. This causes frequent scanning of the file for matching parens, braces, etc. which can drastically slow Vim down when the file is on a network share. Again, this should go in your vimrc.

let g:loaded_matchparen = 1

If you only want to disable the plugin temporarily, you can use the command :NoMatchParen and then :DoMatchParen to re-enable it later in that Vim session.

Finally, if none of those help you can always copy the file locally and edit it.


A follow up on jamessan's answer: to disable the plugin automatically when you edit files on a share, put this line in you _vimrc

autocmd BufReadPre //* :NoMatchParen