Monday, October 01, 2007

vim on slow links (sshfs)

Sometimes (as today), I need to edit files remotely. If the bandwidth is slow (PLDT myDSL has some occasional bogosity where my route to the office, which is normally just 5 hops, bounces between two internal routers whose IP addresses differ only by 1 in the last octet, so then my vpn goes to the other links and the hop count goes to 18 or so because it's overseas), editing remotely is intolerable.

Then I go with sshfs. I've got a script that mounts my working copy over sshfs. I always need to remember to setup vim though to not use swapfiles. So, from the man page,

-n No swap file will be used. Recovery after a crash will be impossible
Handy if you want to edit a file on a very slow medium (e.g. floppy).
Can also be done with ":set uc=0". Can be undone with ":set uc=200".

I've got an annotation in my ~/.vimrc (normally commented out) to set uc=0,
but I forget that it's there and I always google for sshfs vim swap file. And
then I go to this page, which doesn't have the answer :-).

I would post the solution so that the question doesn't stay unanswered indefinitely. If I could reply without joining the group I'd do that. But joining is required, and I'm no joiner. So the best I can do is point at it here.

Heheh, this will also help ME since I would normally query something like:

monotremetech sshfs vim swap

:-)

2 comments:

krxlprnft said...

You can set the swap and backup directory of vim:

set directory=~/.vim/swaps
set backupdir=~/.vim/backups

and gone are those annoying swps, off to a better place ...

Bopolissimus X Platypus said...

Cool. Yeah, there's a *lot* in vim that I don't know, let alone even know *about*. I learned vi on some old AT&T unix and I've resisted learning vim specific things for a long time.

I suppose I *might* eventually work on some solaris or other unixen that don't have vim, but there's probably no reason to not start using some vim-only features, much in the way I just assume that I'll work only on bash and don't mind using bash-only features :-).

Heh, I've put those config directives in my version controlled .vimrc. I don't actually use that config *everywhere* since different boxes I work on have different standards, and the sysadmins or server owners set the standards. But I use my version controlled .vimrc as a reference and template.