Matthew Fitzsimmons

Make Vim Play Nicely with ExpanDrive and Mountee (and Transmit Disk)

I've been having real sluggishness issues when trying to edit ExpressionEngine template files using MacVim and Mountee, or trying to edit any files using MacVim and ExpanDrive.

I'm not sure why it took so long to come to this realization, but I finally figured out the source of the problem: by default, vim saves a swap file in the same directory as the file you're editing. This means that when you're trying to do simple editing tasks with a file stored on a server and accessed via one of these methods, vim is making a lot more calls to the server than necessary because it's trying to save actions to the swap file.

After a little searching, I discovered there is a very easy fix: tell vim to save the swap files somewhere else. There are a couple of ways to go about this:

If you just want to implement the change for the current session, you can just enter this command in vim (replacing .vimswap with whatever directory you actually want to use for this purpose):

:set directory=~/.vimswap

The alternative is to add this to your config file if you want to do this all the time. You could add it to .vimrc or .gvimrc. Personally, I went with .gvimrc. The reason for this is that it only activates when I'm using the gui version of vim (MacVim in this case). This is handy because I use git to push my vim configs to certain servers, and I don't want to use this setting when I'm making changes using vim on a server. Because I put the setting in .gvimrc, it won't activate when I'm doing command-line editing on one of these servers.

This should work just as well for people using vim and ExpanDrive on Windows.