vi style key bindings in Firefox
October 9th, 2006 by RohanWhat a huge browsing improvement this gave me. I always found myself pressing j or k instead of the up/down arrow keys. I learnt how to edit the Firefox key bindings from an article which I don’t remember the link to.
Its quite simple though
- Open folder “Your firefox installation directory”/chrome. I use a linux box, and my Firefox version is 1.5.0.7, so for me this was
/usr/lib/firefox-1.5.0.7/chrome - Unzip the file toolkit.jar (You may want to take a backup of this file first)
- Open content/global/platformHTMLBindings.xml in your Editor
- Change your keybindings as required. Here’s what my changes look like:
<handler event=”keypress” key=”k” command=”cmd_scrollLineUp” />
<handler event=”keypress” key=”j” command=”cmd_scrollLineDown” />
<handler event=”keypress” key=”h” command=”cmd_scrollLeft” />
<handler event=”keypress” key=”l” command=”cmd_scrollRight” /> - Some additional changes I did
<handler event=”keypress” key=”g” command=”cmd_beginLine”/>
<handler event=”keypress” key=”g” modifiers=”shift” command=”cmd_endLine”/> - Save the file and zip the contents folder back into toolkit.jar
- Restart Firefox
The modifiers attribute is really helpful. That last one which replaces my “End” key is “G”.
Also helpful to know, is that the space key is for PageDown, and shift+space is for PageUp
