Skip to content

Emacs/Readline keys in Firefox and other GTK applications


That article describes how to set the basic keys for moving around (Ctrl+F/Ctrl+B to move, etc.)

However, if we really want to be authentic, we should add the ability to scroll with Ctrl+N/Ctrl+P, and yank (paste) with Ctrl+Y.

A bit farther down that page in the guide, it asks us to extract a jar. If you’re missing a ‘jar’ command, doing

sudo aptitude install openjdk-6-jdk

should sort you out.

The guide says to copy


to a directory of your choice. However, if you have trouble (like I did) locating toolkit.jar, you can use

sudo find / -wholename *chrome/toolkit.jar 2>/dev/null

to hopefully locate the file. For me, it was located in /usr/lib/xulrunner-, so:

mkdir tmp && cp /usr/lib/xulrunner- tmp/

did the trick.

Let’s make a backup of that .jar just to be on the safe side, with

cp toolkit.jar toolkit.orig.jar

With any luck, you now have toolkit.jar in ~/tmp and you’re ready to do

cd tmp && jar -xf toolkit.jar

which will extract the .jar file. Try the command ‘man jar’ if you are interested in learning more about the ‘jar’ command.

Now, use your favorite text editor, vi, emacs, nano, gedit, or whatever suits you and open the file, e.g.

vi content/global/platformHTMLBindings.xml

And insert these lines, according to the guide:

<!-- Emacsish multi-line motion and delete keys -->
<handler event="keypress" id="key_linedown" key="n" modifiers="control" command="cmd_lineNext"/>
<handler event="keypress" id="key_lineup" key="p" modifiers="control" command="cmd_linePrevious"/>

This file looks like it holds a lot of potential for hacking keys in Firefox, so while you’re in there, have a look around and feel free to experiment! After all, if we break something, we have a backup. Have fun!

UPDATE: Adding the Ctrl+N/P handlers WILL break the up and down arrows. There’s some stuff in the documentation about this… Updates will follow as knowledge increases in that domain…

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: