Modify Remote Files with VIM’s Built in FTP Plugin

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!


Was this information useful?


9 Responses to "Modify Remote Files with VIM's Built in FTP Plugin"
  1. Jade Robbins on June 3rd, 2008

    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?

  2. Mark Sanborn on June 3rd, 2008

    Jade,

    For samba shares I would just mount it with smbfs.

    This supports:
    Rsync
    scp
    ftp
    sftp
    http

  3. Jade Robbins on June 3rd, 2008

    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!

  4. Jade Robbins on June 3rd, 2008

    P.S. <3 Vi 4 LYFE!

  5. Using Markers in Vim on June 9th, 2008

    [...] 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 [...]

  6. arn on December 9th, 2008

    may i ask where the password should go? :)

  7. Mark Sanborn on December 10th, 2008

    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.

  8. VIM on September 8th, 2009

    Please share the URL for the plugin also.

  9. Mark Sanborn on September 9th, 2009

    @VIM

    The plugin is built into vim. :D