Your Vim May Vary 1 – SCP Editing

Another thing I’ve been learning about lately is Vim.

In the 11 years I’ve been using Linux, I always stuck to simple text editors – nano was a good choice for me, since it’s pretty much entirely visual and the keybindings are printed at the bottom.  But lately, I’ve been doing more scripting, and I’ve needed more functionality from a text editor, so I started learning how to use Vim.  I’m still not particularly advanced in it, but it’s suiting my needs better.  One of my favorite recent discoveries is the ability to edit remote files using a local Vim – I’ve put a small amount of work into my vim configuration, so I’d like to see my work not go away every time I need to edit a remote file.

It’s a pretty simple thing to access, actually.

vim scp://user@host/relative/path/

vim scp://user@host//absolute/path

The user can be omitted if it’s the same name as your current user, and the relative path is relative to the login directory, usually ~ .  I’d recommend setting up SSH keys, just to make it more transparent (although there are plenty of other reasons to set up keys over password authentication).  From there, Vim will treat it almost exactly like a local file, until you save; the buffer is automatically sent to the remote location when you write it.  Pretty useful if you’re constantly working on remote machines!

Leave a Reply

Your email address will not be published. Required fields are marked *