Using vim to edit remote files

By Confusion on Tuesday 20 January 2009 07:22 - Comments (7)
Category: Software engineering, Views: 5.335

As I know there are many editors out there that can edit remote files, I figured I'd find out whether my favorite editor supported that feature. Of course it did :). Just use
ftp://user@server/path/to/file

to locate the file, enter the password and happily edit away. Every :w will upload the file anew. This also works with at least scp:// , so there's no need to install an ftp server.

One small inconvenience is the fact that if you're NATed behind a firewall, you need to use ftp PASV mode, which is not the default setting for many ftp clients. However, Google brought an easy solution: add
let g:netrw_ftp_cmd="ftp -p"

to your ~/.vimrc. This latest tip thanks to: http://alecthegeek.wordpr...etrw-in-ftp-passive-mode/

edit:
Note that the above indicates a relative path on the server. If you want an absolute path, you need to add an extra /: ftp://user@server//absolute/path/to/file

Volgende: De Vrienden van Amstel Live 01-'09 De Vrienden van Amstel Live
Volgende: Nieuwsartikelen niet goed lezen, maar er wel op reageren 12-'08 Nieuwsartikelen niet goed lezen, maar er wel op reageren

Comments


By Tweakers user froggie, Tuesday 20 January 2009 08:49

Thanks for sharing! I didn't know this but editing files over scp can safe me some time here and there.

By Tweakers user MaxxMark, Tuesday 20 January 2009 10:49

Nice! Didn't know that one.

I mostly develop on the remote machine or I develop on a local installed development machine (and ftp/scp it when i'm done). But it can be very handy when you want to edit a remote file quickly. Thanks for the tip!

By Tweakers user Motrax, Wednesday 21 January 2009 07:54

VIM supports everything. Too bad that when you really want to use al the features present, you cannot escape from the command line. And then you need to know which features are present and what the syntax is...

Too bad. The only thing preventing VIM to take over the world!

By Tweakers user Erik, Thursday 22 January 2009 22:34

Every :w will upload the file anew. This also works with at least scp:// , so there's no need to install an ftp server.
But if the file you're editing is located on a computer you have ssh access to... then why bother? Chances are high vi(m) is installed on the remote system ;)

By Sync, Friday 23 January 2009 09:39

@Motrax: I'm not sure but have you tried xvim?

By Tweakers user Confusion, Monday 26 January 2009 08:14

@Erik: that is true, but sometimes only a 'different' or limited vi(m) is available, in which case I prefer my local version, with proper settings, highlighting, etc. (I'm specifically thinking of the Solaris 9 machines over here).

By Tweakers user Ghost, Tuesday 27 January 2009 23:31

Cool, always nice to learn a new vim trick.

Confusion, did you know you can import a dutch ispell dictionary to use in vim? I found that particularly useful, since I am writing most of my documents using vim.

Comments are closed