Tip #317: Mozilla Vim Keybindings
tip karma |
Rating 70/25, Viewed by 1656
|
created: |
|
August 21, 2002 21:23 |
|
complexity: |
|
basic |
author: |
|
Matthew J. Stott |
|
as of Vim: |
|
5.7 |
If you use VIM you like the h, j, k, and l movement keys. I found myself annoyed at not having these movement keys available when browsing web pages. Moving to the arrow keys on a laptop is annoying to just scroll the page.
Locate your mozilla/res/builtin directory (varies by platform). You could search for htmlBindings.xml to find it. (ie. locate htmlBindings.xml.
On Mac OS X it's inside the Mozilla application bundle. /Applications/Mozilla/Mozilla.app/Contents/MacOS/res/builtin.
Create a new XML file called userHTMLBindings.xml, making it executable for all users and making sure the CRLF format is the same as htmlBindings.xml. i.e. on Mac OS X most files use \r but Vim writes \n instead. You can either save the file with Vim as a Mac formatted file or use tr '\n' '\r' < input.xml > output.xml to convert the file.
Place the following XML into the userHTMLBindings.xml file.
<?xml version="1.0"?>
<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="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"/>
</handlers>
</binding>
</bindings>
There are many more bindings one could configure to get Vim like keybindings. You can read http://www.mozilla.org/unix/customizing.html#keys for more information.
PS. I love the keymaster/gatekeeper xul reference in the xul URL above. It's from the original GhostBusters movie. ;-)
<<Using /pattern/ search in a script |
Extended Bracket and Parenthesis + extras for perl >>
Additional Notes
|