Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GVim runs very slowly when editing files on a windows share

On my computer at work, any time I open a file located on a network share, GVim becomes completely unusable. Scrolling through the document can take 15 seconds to go one "page". Even using the movement keys to go from one word to another can take 2 to 3 seconds. This seems to be a new behavior, but for the life of me I can't remember changing anything that would cause it. I'm under the impression that Vim doesn't actually access a file except on open and on save. Is that right?

like image 987
bshacklett Avatar asked Jan 20 '10 18:01

bshacklett


2 Answers

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.

like image 193
jamessan Avatar answered Oct 03 '22 00:10

jamessan


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?

like image 44
David Anderson Avatar answered Oct 03 '22 01:10

David Anderson