Saturday, April 29, 2006

vi key bindings and Firefox 1.5

This is shamelessly copied from http://forums.mozillazine.org/viewtopic.php?t=292404&highlight=keybindings These guys were there before me. I am adding some more details to this page.

I am a vi addict. I use vim everywhere including windows, unix, linux. I have learnt typing and type very fast. I hate to move my fingers for navigation keys or mouse from the asdf position. I open vim where everybody opens a notepad, wordpad or any advanced editor. I use inbuilt ftp client to pullout files from servers and edit directly. It saves me lot of time.
The beauty with firefox is I can customize it to my taste. Now for a long time I felt I am missing some kind of vi/vim navigation in firefox browser.

1. Get a jar package. If you are like me (an illiterate) in java, get java development installed on your system. I use cygwin and I downloaded gcj package to get the jar. Otherwise, the standard Sun JDK will have jar bundled.

2. Copy toolkit.jar to a tmp dir found under Mozilla Firefox\chrome. This dir will be usually under c:\Program Files or wherever you installed Firefox 1.5.

3. Open, unjar (untar) the jar file. jar -xvf toolkit.jar. The contents will be stored under content/ dir. Open the file content\global\platformHTMLBindings.xml in your favourite editor (in this case vi) and add the following to the browser section.

<handler event="keypress" key="h" command="cmd_scrollLeft" />
<handler event="keypress" key="j" command="cmd_scrollLineDown" />
<handler event="keypress" key="k" command="cmd_scrollLineUp" />
<handler event="keypress" key="l" command="cmd_scrollRight" />
<handler event="keypress" key="u" command="cmd_scrollPageUp" />

You can add other bindings as well and it depends on your preference.

4. tar... sorry jar is back again using jar -0cvf toolkit.jar content/ . Note the zero which allows jar to tar the contents rather than compress.

5. Take a backup copy of toolkit.jar found in firefox chrome dir and copy the modifed file into that location. Restart Firefox and you got it.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.