DEV Community


vim ssh

Serhat Teker
Uomo Universale | Software Engineer | Entrepreneur | builds systems | py:js:go |
Originally published at on ・1 min read

If you want to edit files on a remote server with your current lovely vim configs there are 2 options:

One is to copy your .vimrc to all servers. Which is not efficent and denying one of the main software development principle - DRY (Don't Repeat Yourself).

Another one is instead of bringing .vimrcto each server you need to work on, edit the remote files from your local vim:

Start vim like this:

$ vim scp://remoteuser@host//path/to/file/file.extension

If you have already a vim session:

:e scp://remoteuser@host//path/to/file/file.extension
  • remoteuser is the user name on the remote server
  • host is the remote server name/ip

This opens the file seamingly in place (it actually copies the file locally), and when you save, it sends the edited file back to the server for you.

It asks for an ssh password, but this can be streamlined via ssh keys.

The only drawback of this method is that you don't get path/file competion as you would when working directly on the machine which is not a big deal beside advantages.

All done.

Discussion (1)

konstantin profile image

IMHO there is also

Just mount remote folder locally and let system handle the file changes