Builder Update

Another week has passed of feverish hacking on Builder.

Change Monitor Update

My previous change monitor used signals on a GtkTextBuffer to track what had changed. It wasn't perfect, but it was light on resources. Shortly after that post Ignacio Casal Quinteiro informed me that libgit2-glib was up to the task. So over the weekend I ported the change monitor code to use GgitBlob to perform file differences. It seems to work well, and is pretty immediate even on 10,000 line files like gtktextview.c. Good enough for me.

The only lost feature is that we lose change tracking on files not in git. Not ideal, but suitable since we will eventually be managing file creation in the projects and can just add new files to the git index.

VIM

In the process of writing Builder inside of Builder, I felt I was being slowed down by my lack of VIM-style modal editing. I used vi the first time circa 1998 and it has been my primary editor since. That leaves me in quite a bind with things like GtkTextView.

This week, I sat down to solve this "problem" so that I can use Builder full time to write code (which I've achieved).

The result is a fairly comprehensive, but by no means "complete", implementation of VIM modal editing for GtkTextView or GtkSourceView. It's practically impossible to have a "complete" VIM implementation unless you actually use VIM. I didn't want to go down that path because I'm not interested in sub-process editors, text editor abstractions, or the like due to the added complexities. Plus, what better way to learn an editor than to implement it! (Always a good idea, especially when it comes to learning a language).

The result feels so natural to me, it is actually jarring when something isn't the same as VIM in a terminal. In particular, dw doesn't feel quite right because the word boundary engine in Gtk and Pango do not match VIM's. The good news is that Sébastien Wilmet has patches in flight for Gtk that should get us closer to that. In the meantime, I'm retraining myself to use de.

If you'd like to play with this, but don't have a new GNOME 3.14 install (which is required for Builder), you can play with fakevim. It has some features stripped out like command execution and search, since those rely on Builder implementation details. I'd be happy to accept patches from someone wanting to abstract that.

One outstanding item that is not yet supported is replay with the . keystroke. I'll get to this in the not too distant future, I'm just not sure how I want to implement it.

Another missing feature is column selection with Control+v. I actually really like this feature, but I need to investigate non-contiguous selections first. It can probably be done by adding support for something like that into GtkSourceView.

It's unlikely I'll implement VIM registers, but I'd be happy if someone else who actually uses that feature adds it.

One other implementation detail. This only supports commands that are a single keystroke (but they they can be followed by modifiers, and prefixed by numbers). It just means that 3 character commands aren't supported yet. Such an example would be gUw. I'll get to it.

So, things that are supported! Keep in mind that many of these commands can be prefixed by a count, like 10x to delete the next 10 characters or 5dw to delete the next 5 words.

All of this is available in Builder from git master. Simply turn on the Enable VIM compatability mode switch in the preferences window.

If you'd like to watch a video demonstrating some of these features, take a look at http://www.youtube.com/watch?v=xm-D80484h0.

Happy Hacking!

-- Christian Hergert 2014-10-03

Back to Index