Edit files remotly with VIM & SCP

Categories General Info

if you need to make an edit to a file on a remote server simply

vim scp://hostname.example.com//path/to/file.txt (will require username on remote host to be the same as what you have on screen)
root@g33k4l1f3.com's password: (enter pw)
Press ENTER or type command to continue (hit enter, file opens, make edits, then save and close)
:wq
root@g33k4l1f3.com's password: (enter pw)
#

Or, if you need to connect as a different user:

$ vim scp://user@hostname.example.com//path/to/file.txt

If you need to specify an alternate port, use the familiar colon (:) syntax:

$ vim scp://user@hostname.example.com:5757//path/to/file.txt

That’s all there is to it! The file is read into VIM from the remote system, if it exists. Then, you are free to make changes. When you save, changes are written to the remote system.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.