Vim Tip of the Week : August 31, 2007 – Remote Editing

By | 2007/08/31

I’ll preface this post with a quote from one of our local users, findlay:

11:15 < findlay-w> I can edit google's homepage from within vim?!
11:15 < findlay-w> now that's a powerful editor!

That’s right vim is a powerful editor! Now, of course, you can’t publicly change Google’s homepage with vim but you can edit it directly to be saved elsewhere. Same with any other web-based file or file on a remote machine. Here are some examples:

vim scp://user@hostname/path/to/file (remotely edit a file via scp)

vim ftp://user@hostname/path/to/file remotely edit a file via ftp)

vim scp://user@hostname/path/to/dir (remotely show directory contents with the ability to select and edit a file)

And from within vim, if you’d like to open a remote file or create a remote file.

:e http://google.com/ (remotely see/edit the contents of Google's homepage)

:e http://yourwebsitehere.tld/ (remotely see/edit the contents of your homepage)

:e scp://[email protected]//etc/apt/sources.list (remotely edit the sources.list file on another machine via scp)

:e ftp://[email protected]//pub/somefile (remotely edit somefile on another machine via ftp)

...or the examples above prefixed with :e

I’m sure that is enough to get you in trouble–err, I man, started. Enjoy. For more information on how all of this works and additional options, please see the help for netrw within vim (:help netrw).

And that has been this weeks “Vim Tip of the Week!”

6 thoughts on “Vim Tip of the Week : August 31, 2007 – Remote Editing

  1. Jeff Schroeder

    That is pretty cool, but it saves your password in ~/.bash_history an anyone with access to the ps or who commands can see your password in the process tree… not so cool anymore.

  2. walth

    Hmmm I did not see password in ps. There is no password in vim history. Its not true that you can see passwords if someone connect to the web by vim. Password is hidden and unseen for others people.

    Sorry for my poor English.

  3. mlissner

    I don’t know about the password thing, but if you’re connecting via FTP anyway, your password is getting moved in plain text in any event.

    That said, this is the greatest thing I have learned in some time with regards to vim. I love these tips! You’ve set a high bar today.

  4. Joe Smith

    Sweet. I do a lot of remote editing for my server, and if I just want to make a quick change to a file, this is the way I’ll go.

    Thanks Christer!

  5. erez

    That’s not exactly a vim feature, if you try it in Windows, you’ll most likely to get a “cannot find wget” error. The actual vim feature is that it implicitly call other tools, similar to the ! command calling the local terminal.

  6. Steve

    The best thing to do is to use scp and keys. No need to enter annoying passwords, no passwords zooming around in plain text. It’s the easiest, most secure way to do it. If you want to take security that little bit further, turn off password authentication altogether in your /etc/ssh/sshd_config file and just use keys. No-one can get in without your private key which means brute force, dictionary attacks won’t work.

Comments are closed.