foobarfuzzbizz
foobarfuzzbizz

Reputation: 58637

Way to use vim work on a cache of a file instead of the actual file?

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.

Upvotes: 3

Views: 2636

Answers (6)

user80168
user80168

Reputation:

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.

Upvotes: 1

Sinan Ünür
Sinan Ünür

Reputation: 118128

:e scp user@host:/path/file

See :help netrw and :help ssh in Vim.

Upvotes: 0

Schnouki
Schnouki

Reputation: 7707

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.

Upvotes: 0

Chris Boyle
Chris Boyle

Reputation: 11551

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.

Upvotes: 0

chmeee
chmeee

Reputation: 293

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.

Upvotes: 6

DrAl
DrAl

Reputation: 72616

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

Upvotes: 1

Related Questions