VI-bindings in Mozilla Firefox (formerly Firebird)

This method doesn't work since 1.0.6 or something like that. I've learned to survive without VI-bindings.

Use VIMperator instead.

I admit it, I'm a vi addict, I like my fingers kept on the home row as much as possible. Before switching to Firefox, I used the j and k keys heavily in Galeon 1.2.10 to scroll up and down a page. Those keybindings was the only thing I missed in Firefox. Since google couldn't find any specific info about this, I had to get my hands dirty and dig for some info myself.

This is my result, published for other vi addicts to find.

You simply put this snippet of code in a file called userHTMLBindings.xml and place it in res/builtin/ in your firefox installation tree. In my case, using the FreeBSD port, this would be /usr/X11R6/lib/firefox/lib/mozilla-1.6/res/builtin. If you're using Firefox for Windows, and installed it in C:\Program Files\Firefox, the correct place for this file would be C:\Program Files\Firefox\res\builtin\

<?xml version="1.0"?>
<!-- In order to work correctly, this file must be named -->
<!-- res/builtin/userHTMLBindings.xml in the mozilla tree. -->

<bindings id="htmlBindings"
   xmlns="http://www.mozilla.org/xbl"
   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <binding id="browserUser">
    <handlers>
      <handler event="keypress" key="k" command="cmd_scrollLineUp"/>
      <handler event="keypress" key="j" command="cmd_scrollLineDown"/>
      <handler event="keypress" key="l" command="cmd_scrollRight"/>
      <handler event="keypress" key="h" command="cmd_scrollLeft"/>
    </handlers>
  </binding>

</bindings>
	

These keybindings works best if you use the / and ' keys to activate find-as-you-type. You can turn that on by putting the following code in your user.js.

// Find As You Type Configuration:
// Set this pref to false to disable Find As You Type:
user_pref("accessibility.typeaheadfind", true);
// If you set this pret to true, typing can automatically start Find As You Type.
// If false (default), you must hit / (find text) or ' (find links) before your search.
user_pref("accessibility.typeaheadfind.autostart", false);
// Set this pref to false if you want Find As You Type to search normal text too:
user_pref("accessibility.typeaheadfind.linksonly", false);
// Set this pref to true if you require that the link starts with the entered text:
user_pref("accessibility.typeaheadfind.startlinksonly", false);
// This is the time in milliseconds for the Find As You Type to stop watching for keystrokes:
user_pref("accessibility.typeaheadfind.timeout", 3000);