Gnome-Vim

What is Gnome-vim?

Gnome-vim is a project to support embedding Vim as a bonobo component. This will allow any other gnome program to easily embed Vim as a editing component (not some scaled-down version, but the full editor, complete with GUI menus and toolbars). This lets you:

News

June 15, 2004: I've updated the vim patch to apply cleanly to the latest vim CVS. I want to work at cleaning up my vim patch in the hopes that it will be accepted into the official vim distribution.

June 7, 2004: Tony White has implemented a solution for opening files from gnome-vfs mounted volumes (limited to SFTP/FTP). People may find this useful, at least until proper gnome-vfs support gets implemented in vim.

March 25, 2004: Anuradha Ratnaweera contributed an updated version of the evo patch for Evolution 1.4.6.

On the Evolution front, I should mention that the patch didn't actually make it into Evo 2.0 -- I submitted it and it got the green light, but it was forgotten about and didn't get committed before the code freeze. I'll resubmit it after 2.0 is released and make sure it gets committed.

January 15, 2004: There was a bug in the makefile. The Vim_Control.server file was being generated in the installbonobo target instead of the default target. So if a different prefix was being passed to make for the install phase (as is the case when creating a deb or rpm package), the paths in Vim_Control.server were incorrect, which caused instantiation of the vim control to fail.

I've released a new vim patch which fixes this, and built a new vim-bonobo .deb too.

Thanks to Markku Korkeala for alerting me to the problem.

January 13, 2004: I fixed a bug which could cause evo to crash if the gconf key was unset/empty. Created updated patches and put an updated evo i386 binary in the apt repository: evolution-1.4.5-3jh2. Also added the source files for the .deb to the repository, to make it easier to build on other architectures. Will have to see if my patch can be put in the official debian evo packages...

January 11, 2004: I built a vim-bonobo .deb and put it in my apt-repository. This means debian users shouldn't have to build anything themselves, just install and go.

January 10, 2004: Updated and released vim-bonobo patches, as well as evolution patches which enable using vim-bonobo. Updated the instructions and documentation on this page. I submitted the evo patch to Ximian a couple of days ago and have since made several revisions to get it ready to be merged into CVS. It looks like they're nearly ready to commit it.

January 7, 2004: I'm made slow but steady progress in the last few months. I'm happy to report that Gnome-vim is working well with Evolution. For now I've side-stepped the keypress-conflict issue by patching evolution to not catch the escape key if Vim is being used as the editor component. I hope this is acceptable to the Evo team, as I hope to submit this patch as soon as possible to have it included for Evo 2.0 (feature freeze is coming up!).

After that I'll be preparing a new release of the gnome-vim patch and making it available for download.

August 4, 2003: Updated patch to apply cleanly to current Vim CVS. The GTK2 support was merged into CVS a few months ago, so it is no longer necessary to apply this patch.

No, I haven't given up this project; I've just been busy with other (read: paid) work. I'll continue to work on it as time permits.

The current biggest obstacle to Vim working well in Nautilus and Evolution is the "Keypress Conflict" issue described below. Hopefully it will be possible to resolve this.

March 22, 2003: First developer release of the code. The basic stuff is now in place:

There is still much work to be done, and I think we're now at the stage where parallelization is possible (my time for this project is limited). See below for a list of things to work on. If you want to help, email me and let me know what you're working on, so that I can update this page.

February 12, 2003: Now that the GTK2 support is in place, I'm back at work on bonobo-izing vim. After a solid evening of hacking last night, I was able to get vim running as an out-of-process bonobo control. I've commented the menu/toolbar code out just so that I could get something working, but I'll be porting that soon, too.

November 28, 2002: Progress on the gtk2 support in vim is progressing; the discussion is taking place on the vim-dev mailing list. You can download my current patch and/or read my to-do list here.

November 22, 2002: After a long break, I've finally started work on the next-generation gnome-vim component, which will work much better than the old one and will feature toolbars and menus just like gvim does. So far I have ported the existing gvim code to use gtk2.0. I'm going to clean up this patch, and then submit it to the vim team to put into CVS. After that I'll begin work on the component itself.

Older news...

Issues/Todo

If you want to help, this is a great project for getting your feet wet with bonobo. Email me and let me know what you're working on, so that I can update this page. Here is a rough roadmap of things (in no particular order) which need to be done:

IssueDescriptionStatus
Re-opening saved drafts in Evolution doesn't work Vim fails to start -- it could be crashing. Not started.
Menu Priorities The top-level menus (i.e. File, Edit, etc.) need to be ordered according to the priorities in the vim menu structures. Not started
Toolbar resizing Vim supports different sizes of toolbar icons as well as modes for text/icons/both. We need to take this into account and update the merged toolbar when the user changes the settings. Not started
Keypress Conflicts

Vim needs certain key events to be useful, even if the container app has assigned these keys as menu accelerators. Nautilus, for example, uses Escape, CTRL-R and CTRL-N. Evolution adds a keypress handler which closes the composer window if Escape is pressed.

There are two solutions to handling problems of this type. The first is to modify each container application. This takes time to do, and as Vim has a comparatively small audience, convincing maintainers to merge in these patches would be difficult. The other solution is to modify GTK to give embedded applications (GtkPlug objects) an opportunity to handle these keypresses first.

It appears that this issue will require changing the XEmbed protocol. Since I don't know if I have enough time or clues to do carry this out, I've sidestepped the issue (at least in Evo) by patching Evo to not catch the Escape key if the editor needs it.
Using Multiple Buffers If you open multiple buffers, Vim should remember which of the buffers is the "embedded file" that Evo is interested in. But it's not yet working 100%, so use multiple buffers with caution. Has not been investigated.
GnomeVFS Support It would be great to implement GnomeVFS support in Vim for loading/saving files, since this will allow Vim to access files using any GnomeVFS backend, from Nautilus or other Gnome programs (or by using URIs on command line), such as ftp, ssh, samba. Vim already does some of these protocols natively, but it would be good to have full GnomeVFS support, too.

A quick run through Vim code suggests that at least the following functions would need GnomeVFS support: mch_isdir, mch_setperm, mch_lstat, mch_stat, mch_remove, mch_set_acl, mch_free_acl, mch_set_filetype, vim_write, vim_fexists.

Until this gets implemented properly, you may be interested in Tony White's solution for opening files from gnome-vfs mounted volumes (limited to FTP and SFTP).

Code cleanup We need to split up gtk_gui.c and gtk_gui_x11.c into more files to reduce the number of #ifdef's to keep things sane. This will involve reordering and reorganizing a lot of the code, and finding abstractions to deal with the bonobo/gtk differences more cleanly. Not started.

Download

Here are the goods: Debian users:

I've put together an apt-repository containing vim-bonobo and evolution (1.4.5) packages for i386. Just add the following line to your /etc/apt/sources.list:

    deb http://www.opensky.ca/~jdhildeb/debian/ unstable/
and then run:
    apt-get update 
    apt-get install -t unstable evolution=1.4.5-3jh2
    apt-get install -t unstable vim-bonobo

Building Vim with Bonobo Support

Here are the basic instructions for getting Vim built with bonobo support:

Using Vim with Evolution

Now Evo should use Vim for editing emails -- give it a try! You'll want to do a couple more things, though. You can write a Vim function called "EvoQuote" which will be called to quote text in the emails (i.e. when replying), and put it in your .gvimrc file. The following function prefixes each quoted line with '> ':

    function! EvoQuote()
      normal msHmt
      %g/^GtkHTML_QUOTE_ON/.,/GtkHTML_QUOTE_OFF$/s/^/> /
      %g/^> GtkHTML_QUOTE_ON/.,/^> GtkHTML_QUOTE_OFF$/s/>      /> /
      %g/^> GtkHTML_QUOTE_ON/d
      %g/^> GtkHTML_QUOTE_OFF/d
      normal 'tzt's
    endfunction
    

(Thanks to Rob Hill for contributing this improved version of my original function).

If you want to set some different vim settings when editing emails (I typically set nocindent and reduce the textwidth to 76 characters), add the following to your .gvimrc as well:

" set email settings when embedded by evolution
" don't give a warning if this event is unknown
try
autocmd EmbeddingOn evolution* :so ~/.vim-evo
catch /E216/
endtry

This will cause the ~/.vim-evo file to be sourced whenever an embedded vim instance is started by evolution. The try/catch is necessary because non-bonobo versions of vim will not recognize the EmbeddingOn event. Put any evo-specific vim settings you want into ~/.vim-evo.

Now before you do any real work, send yourself a few test emails until you are sure it is working properly.

Implementation Notes

Gnome-vim partially implements the GtkHTML interface so that it can be used from Evolution without requiring changes in how Evolution uses the editor.

Most bonobo factories are located in the same executable as the controls they produce. But most factories can produce multiple controls which all live in the same executable. This is not the case for Vim: it's only possible to have one control per process. Because of this, the factory has been implemented as a separate executable, as per the "proxy" option described in this message.

Credits

Thanks go to:

Author

I'm Jason Hildebrand <jason at peaceworks dot ca>. Please send bugfixes, patches and suggestions. Other projects of mine include GSysinfo and Phormation.