Vim Recipes ‣ Display ‣ Working with Remote Files
You want to edit/view a file that is stored on another computer.
For example, you might want to change a file on your website from your home computer. Or, you want to change the message of the day file on a server you administer.
To invoke Vim with a remote file use its URL as the argument to vim. For example: vim sftp://guest@example.com/file.txt.
To work with remote files from within Vim, just use their URLs in place of a filename with normal editing commands.
So, to to open a remote file for editing use :e URL. For example: :e ftp://user@example.com/README.
To save to a remote file use :w URL. For example: :w scp://kci@jojo.example.com/etc/motd.
Vim supports the following protocols: SCP, SFTP, RCP, HTTP (read-only), WebDAV, rsync (read-only), and fetch (read-only). However, it relies on external programs to do so. On Linux, most of these programs are available by default; on Windows, for example, only FTP is normally available. See :help netrw-externapp for more information.
If the protocol requires authentication, you can supply the username as part of the URL, and then be prompted for the password interactively. This gets boring fast, however.
If you're editing files via SSH or SCP consider setting up passwordless logins. The principle is explained in Password-less logins with OpenSSH for Debian Linux, but it is much for the same for other operating systems.
If you're using FTP on Linux, you can store your credentials in ~/.netrc'. The file is formatted as follows:
machine {host name 1}
login {username}
password {password}
machine {host name 2}
...
It should be made read-only for your user: chmod 600 ~/.netrc Windows explanation?. Now you can use URLs like ftp://example.org/README, and it will find your username and password automatically.
⚠ FTP is an insecure protocol, so please don't use it unless you must. SSH/SFTP/SCP are all superior alternatives.