Vim and Gnome-VFS

I spent a chunk of the weekend implementing Gnome-VFS support in Vim. Originally I had thought to do this by changing the Vim core (in C) by wrapping function calls like open, write, close, stat, etc. to use the gnome-vfs equivalents. I realized that this approach would be a lot of work, though, because those routines are not just used to load/save buffers, but also temporary files and any other IO that Vim does. Auditing all of the code would be very difficult, and in cases where Vim wants to deal with local files, it doesn't make sense to do this via the gnome-vfs functions.

Besides, Vim already has support for ftp, scp and a few other protocols by means of the netrw plugin (which is included in the vim distribution).

I discovered that gnome-vfs ships with a tool called "gnomevfs-copy", which can copy from one uri to another. This is essentially the same thing you do with scp, but much more general, as it works for all valid gnome-vfs uris.

Using gnomevfs-copy, I added gnomevfs support to the netrw plugin. That meant learning a lot more vim-script, but I'm very happy with the result: using nautilus, I can browse to a remote server (for example using sftp), and click to edit a file in gvim. Gnome-vfs supports more schemes than I thought, including ssh, nntp, sftp, network, tar, gzip, https, rio500, ftp, davs, dav, bzip2, smb, pipe, and http. Using the uri-chaining, it's probably also possible to directly edit a file in a gzipped tar file (haven't tried yet, though).

I will be submitting it to netrw's maintainer, but until then you can get it here.

Update: I renamed the file to have a .vim extension (as it should). To install it, just drop it into your ~/.vim/plugin directory (creating this directory if necessary).

Posted by Jason Hildebrand <> Monday Dec 20, 2004 at 11:25 PM

I am happy to see that you are again hacking the interaction between gnome and vim. I wish that I could make time somehow to help, but, as it is, I am merely hopeful that you will soon focus your attention on the interaction between evolution-2 and vim.

I am grateful for your efforts along these lines in the past, and it appears as though your blog site is shaping up.

Good luck, and best wishes for the holiday season!

Your friendly network-neighborhood debian-sid addict who would use evolution at work for interaction with the company's MS-Exchange infrastructure if only evolution would play well with vim,


Posted by: Thomas E. Vaughan on Tuesday Dec 21, 2004 at 8:54 AM

Thanks for the encouragement, Thomas. I _am_ currently using vim-bonob with Evolution 2.0, but it has a few glitches, namely signatures aren't working (they don't get inserted into the emails), and the window sizing isn't quite correct. So it's useable, but is a regression from how it worked under Evolution 1.4.

So far I've tolerated these bugs myself, but wanted to fix them before releasing a new evolution .deb. Thanks for being patient.

Posted by: Jason on Tuesday Dec 21, 2004 at 10:41 PM

Considering the historical popularity of vi, I'm surprised this hasn't already been done. As far as you know, has anyone else tried to integrate VIM and GNOME?

Posted by: Eric Radman on Thursday Dec 23, 2004 at 8:27 AM

Eric: Yes and no. Back in 2002 when I first looked at it, the vim source code already had support for compiling Vim to use Gnome dialog boxes and session handling, but no serious work had been done on making Vim into an embeddable component, nor have I seen any efforts to take advantage of gnome-vfs.

I suspect one explanation for this is that although Vim has a large following, many hardcore Vim users still eschew "desktop environments" such as Gnome and KDE. Still, I receive email occasionally asking about Gnome-vim, and my website gets traffic, too, so I know there is at least some interest.

Posted by: Jason on Thursday Dec 23, 2004 at 4:45 PM

Thanks for the work you've done on gnome-vim up until now. It's a good step towards getting a well integrated editor for GNOME. Hopefully one day there will be better support for things like gnome-vfs, a good editor is really one of the last major components that seem to be lacking in GNOME this days.

Posted by: Greg on Saturday Dec 25, 2004 at 11:34 PM

Have you seen this page? It's time for you! :]

Posted by: hey on Monday Feb 21, 2005 at 12:15 AM

I love the work on gnome-vfs, works like a charm, except I can't get Nautilus integration to work :'( Thanks though!

Posted by: Robin Haswell on Friday Aug 5, 2005 at 7:35 AM

fantastic! I wanted this so bad, thanks a lot!

Posted by: david on Sunday Feb 11, 2007 at 2:55 AM