Modify Remote Files with VIM’s Built in FTP Plugin

by Mark Sanborn on June 3, 2008

I can’t tell you how excited I am that I found out about this. Vim has a built in plugin to connect to FTP sites. What this means is that you can modify your web documents from vim without having to save the file and then FTP the file up to the server. With this plugin all you have to do is save your work and it is reflected on the server.

I know jedit and many other programs have this feature built in, but vim is by far a more robust programming editor than jedit when you get used to it. So i was very excited that this was built into vim as well.

If you are one of those guys that make quick edits in notepad, save the file, open your ftp program, type in your username/password and connect to the server and then transfer your files, this will save you tons of time. As you can have both the productivity of Vim with remote editing.

To edit a remote file with vim you can use:

vim ftp://username@yourdomain.com//the/path/to/yourfile.php

Now I know what you are thinking. I don’t always know the path to my files and it would be nice if I could get a directory listing or choose the files like I do when I use my FTP program.

No problem. The default ‘:e‘ command wil open the current diretory. You can also open the root directory like this:

vim ftp://username@yourdoamin.com//

This will open up a directory listing. To open the folder just press enter.

vim directory

Bonus Tips

 
You can turn on vim’s syntax highlighting by using, :syntax on

vim syntax

If you have a dark backgound sometimes the syntax highlighting can be dark. To make it lighter tell vim, ‘:background=dark

Making GVim your Default Text Editor in Gnome

If you want line numbers you can use, ‘:set number‘.

Use VI Functions in the Command Line

Happy programming!

9 comments

I was going to make a snobby comment about just SSH’ing into the box you are editing, but then I realized alot of times I just want to SSH into windows boxes but I CANT! This is perfect.

Does it do smb:// as well?

by Jade Robbins on June 3, 2008 at 10:49 am #

Jade,

For samba shares I would just mount it with smbfs.

This supports:
Rsync
scp
ftp
sftp
http

by Mark Sanborn on June 3, 2008 at 11:40 am #

doesn’t smbfs create a persistent connection? Alot of the servers i connect to have twitchy sysadmins that don’t want a persistent connection like that.

That is cool it supports sftp though, cause that is essentially the same thing as what I wanted.

Thanks!

by Jade Robbins on June 3, 2008 at 11:53 am #

P.S. <3 Vi 4 LYFE!

by Jade Robbins on June 3, 2008 at 11:53 am #

[...] also makes perfect sense to use vim when editing remote files for two reasons. The first being that vim can connect remotely through FTP, SFTP, or SCP. The [...]

by Using Markers in Vim on June 9, 2008 at 6:27 pm #

may i ask where the password should go? :)

by arn on December 9, 2008 at 1:59 am #

arn, I think you can do:

vim ftp://username:password@yourdoamin.com//

But I wouldn’t recommend it. It’s best to type it in when after you issue the command.

Also, you will need the full version of vim to do this. Some distributions come with just a light package that doesn’t have this built in plugin.

by Mark Sanborn on December 10, 2008 at 4:31 pm #

Please share the URL for the plugin also.

by VIM on September 8, 2009 at 10:40 pm #

@VIM

The plugin is built into vim. :D

by Mark Sanborn on September 9, 2009 at 10:06 pm #