This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
created 2003 · complexity intermediate · author Roberto · version 6.0
I'm frequently editing files remotely, but if the network traffic is tight, then a normal Vim session turns into a tortuous event. The solution to that was right under my nose: Vim's Network-Oriented File Transfers (:help netrw).
Instead of editing the file remotely, it can be transfered from the host server, to a local copy, edited and then sent back when done. I know that you can do this manually, but it's a hassle, besides, if it can be done automatically, why not go for that?
You need the following installed and properly configured:
- netrw.vim (distributed with Vim)
- scp, rcp, ftp or ftp+
To use, all you need is to specify the protocol, user, host and path to the file you want to edit:
- vim scp://email@example.com//var/www/html/rtc_functions.php
- gvim scp://firstname.lastname@example.org//var/www/html/tips/add_tip.php
Every time you write the file (:w etc) the file will get copied over to the source and you will be brought back to your session for further editing.
If you already have an open session, then just issue the following commands:
To read/load up a file:
To write the file back:
That's it! You'll be editing at local speed.