My Weblog
07 06 2004

Mon, 07 Jun 2004

Vi Keybindings for Firefox
I have finally figured out how to make firefox recognize vi keybindings. Below are the steps required to make it work on Debian boxes (most of them work for all unix platforms):

1. Copy /usr/lib/mozilla-firefox/chrome/browser.jar to your $HOME/.firefox/default/xxxxxx.xxx/chrome directory.
2. Unzip browser.jar and edit the content/browser/browser.xul file, adding the following lines to the end of the section:


<key  key="," command="Browser:Back"/>
<key  key="." command="Browser:Forward"/>
<key  key="a" command="Browser:Home" />
<key  key="r" oncommand="BrowserReload();" />
<key  key="r" oncommand="BrowserReloadSkipCache();" modifiers="shift" />
<key  key="n" command="cmd_findAgain" />
<key  key="n" command="cmd_findPrevious"  modifiers="shift"/>
<key  key="o" command="Browser:OpenLocation" />
<key  key="O" oncommand="focusSearchBar();" modifiers="shift"/>
<key  key="w" command="cmd_newNavigator" modifiers="shift"/>
<key  key="w" command="cmd_newNavigatorTab"/>
<key  key="q" command="cmd_close" />
<key  key="q" command="cmd_closeWindow"  modifiers="shift"/>
<key  key="f" command="View:FullScreen" />
<key  key="z" command="cmd_textZoomReduce"  />
<key  key="z" command="cmd_textZoomEnlarge" modifiers="shift"/>
<key  key="s" command="View:PageSource" />
<key  key="i" command="View:PageInfo" />
<key  key="b" command="Browser:AddBookmarkAs"  modifiers="shift"/>
<key  key="b" command="viewBookmarksSidebar" />
<key  key="h" command="viewHistorySidebar" modifiers="shift"/>
<key  key="d" command="Tools:Downloads" />
<key  key="p" command="cmd_print"  modifiers="shift"/>

3. Edit the $HOME/.firefox/default/xxxxxx.xxx/chrome/chrome.rdf file. Add the following attribute to the tag (below is the example from my chrome.rdf file):

c:baseURL="file:///home/ryan/.firefox/default/m2ukjd2m.slt/chrome/content/browser/"

4. Copy /usr/lib/mozilla-firefox/res/builtin/platformHTMLBindings.xml to /etc/mozilla-firefox.
5. Run 'dpkg-divert --rename /usr/lib/mozilla-firefox/res/builtin/platformHTMLBindings.xml'.
6. Run 'ln -s /etc/mozilla-firefox/platformHTMLBindings.xml /usr/lib/mozilla-firefox/res/builtin'.
7. Add the following lines to /etc/mozilla-firefox/platformHTMLBindings.xml at the end of the section:
  
<handler event="keypress" key="a" modifiers="alt" command="cmd_selectAll"/>
<handler event="keypress" key="u" command="cmd_scrollPageUp" />
<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"/>
<handler event="keypress" key="g" command="cmd_scrollTop"/>
<handler event="keypress" key="g" command="cmd_scrollBottom" modifiers="shift"/>
<handler event="keypress" key=";" command="cmd_findTypeLinks"/>
  
Steps 4-6 prevent dpkg from replacing the modified file with the one in the package. If you're not running Debian, you can skip them and put the above lines straight into the platformHTMLBindings.xml file. You should be able to put the above lines into userHTMLBindings.xml in your chrome directory, but there is a bug in mozilla and firefox that prevents this from working. For now, doing steps 4-6 basically turns platformHTMLBindings.xml into a system-wide configuration file that will be preserved between upgrades.

posted at: 18:10 | path: /computers/linux/apps/firefox | permanent link to this entry