Edit files remotely via VIM & SCP

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.

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

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