tags:

views:

288

answers:

6

I typically ssh to another computer to do my development, using vim (don't post "Use Emacs" please). However, I notice that vim is very slow when my internet is slow (duh).

EDIT: I use a terminal on my local machine and open the remote file with a vim scp://host/file command. However, when I do this, every keystroke that I put in causes vim to go to the network, dramatically slowing things down. Instead, I want vim to read the remote file, let me do my local editing, and only go to the network when I do a :w command. Think of it like a write-back cache option.

I know Komodo Edit offers this functionality, which is where I got the idea from.

+1  A: 

Vim has a plugin (which I believe is standard on most recent vims) called netrw. This basically does what you want I believe: it allows you to open a file on a remote server by copying it transparently.

See :help netrw or The Vim Script page

Al
+4  A: 

You can edit from ssh directly in vim like this:

:e scp://[email protected]//path/to/document

You can find more information in this serverfault question.

chmeee
Just wanted to add `rsync://` to this, as `scp://` will be slow on large files
Hasturkun
This is achieved through the netrw plugin: on earlier versions of vim, this had to be installed manually. This may be relevant if you don't have control of which applications are installed on your PC.
Al
A: 

I find sshfs very useful for this. It can mount a remote directory over sftp, and then you can run vim (or anything else) locally. On current Ubuntu you can sudo apt-get install sshfs.

Chris Boyle
A: 

I don't know if it is possible to do that in vim itself, but if you're using Linux you may be interested in sshfs. It uses FUSE (Filesystem in Userspace) to mount a remote directory into a local one using ssh, and you can then use this remote directory as if it were on your own local computer. It is very robust and reliable (if your ssh session is closed, it will reconnect automagically and you probably won't even notice it...).

I use it almost every day, and it's really a great piece of software.

Schnouki
A: 

:e scp user@host:/path/file

See :help netrw and :help ssh in Vim.

Sinan Ünür
+1  A: 

If you open vim scp:/// and it is slow, and there is network traffic on every keystroke, then something is definitely wrong. Vim should generate network traffic only on save.

Perhaps you turned on autosave? If yes - turn it off for remote files, or at least make it less intrusive.

depesz