Jérôme Belleman
Home  •  Tools  •  Posts  •  Talks  •  Travels  •  Graphics  •  About Me

Pentadactyl

2 Feb 2013

This post is an introduction to using Pentadactyl, which has to be the most tremendous Firefox add-on in the whole history of Firefox and add-ons combined.

1 Vimperator or Pentadactyl?

Pentadactyl is a fork of Vimperator. I've been using both alternately over the years but I always enjoyed coming back to Pentadactyl. Was it because it felt faster, more stable, more versatile? Or maybe just because I was used to it or because it worked with the setup I'd built over the years? Hard to say. They're both worth a look. But what follows in this post will be more specific to Pentadactyl.

2 Installing Pentadactyl

The Download Pentadactyl button on the Pentadactyl home page will install a version which has not been updated for years at the time of writing. It's not a bad sign at all, though, get the source code from GitHub and build it yourself, it's trivial and I never had to install any particular dependencies to make it work:

git clone https://github.com/5digits/dactyl.git
cd dactyl
make -C pentadactyl xpi

An XPI module will be written to dactyl/downloads – give it to Firefox and you're good to go.

3 Getting Started

The :help command will open the help page (which will be opened anyway if you've just installed Pentadactyl) and it's good enough that I won't bother describing the main concepts here. And if you're used to Vim, you'll feel right at home immediately. In what follows, I'd just like to share some of the most interesting features it has to offer.

4 Filling In Forms with Vim

I truly love the fact that you can edit just about anything in an HTML form by firing up the editor of your choice (it doesn't even have to be Vim). Pentadactyl will create a temporary file which your editor will effectively write to before dumping its contents back into the HTML form when the editor exits. The 'editor' option is by default set to:

gvim -f +<line> +"sil! call cursor(0, <column>)" <file>

... and I'd like to bring that up to show the attention to details: the position of your browser cursor in the HTML field will be picked up by this command line to have Vim set its cursor to the same position. It just can't get any more convenient than this. I don't use gvim myself and I've:

set editor='urxvt -e vim -f +<line> +"sil! call cursor(0, <column>)" <file>'

5 Macros

Macros are as powerful in Pentadactyl as they are in Vim. Recording them on the fly to program repetitive actions is as natural as breathing is. For instance at CERN, we use ServiceNow to track incidents and it can happen that serious ones cause the creation of many tickets. Once the problem is solved and there's more than 100 tickets to close with the same resolution message, I'm very glad to be able to do so in a jiffy by lazily recording a macro to close one ticket and repeat this a 100 times over in less than 10 keystrokes. In fairness, ServiceNow does offer features to perform such bulk operations, but somehow it's just more convenient to do so with Pentadactyl.

6 Plug-ins

If you know your JavaScript, it's a doddle to write Pentadactyl plug-ins which can e.g. be used to bind keys to specific operations depending on which web page you're on. For instance, I once wrote a plug-in with a collection of functions for ServiceNow to select and open tickets from a list with vi bindings, to take tickets in progress, to set tickets as Waiting for user, to jump to the Customer View no matter where you are in the ticket, to mark the ticket as solved or to save changes made to a ticket. My personal favourite is the one which opens an external editor to write to the Customer View and automatically greets the user from the ticket information.

7 Pentadactyl for Google Chrome?

No. And it's very sad, this, because I'm not particularly fond of Firefox. It's just absurdly slow and memory hungry. In fact, the only thing that keeps me from leaving Firefox is that it's the only browser for which Pentadactyl is available. It's probably partly got to do with the fact Google Chrome uses sandboxes and you can't easily provide those convenient features such as editing text into HTML fields with an external editor.

Sure enough, there's extensions such as Vimium and cVim but they just can't compare. If you've used Pentadactyl/Vimperator before, there's just nothing else you'll ever want to use.

8 Beyond the Browser

Both Pentadactyl and Vimperator offer similar add-ons for other programs. Teledactyl on the one hand will for instance add vi bindings to Thunderbird. Muttator on the other hand will in addition attempt to remind the user of the mutt experience. The Vimperator developers even went further with Vrapper and VsVim which bring more of the same spirit to respectively Eclipse and Visual Studio.

9 References