Hack and / - Dr hjkl Meets the Vimperator
In November 2009, I wrote an entire column (“Dr hjkl and Mr Hack”) devoted to programs with vi-style keybindings. In the column, I introduced the Vimperator plugin for Firefox and discussed how it worked, but at the time, I mentioned, “The Vimperator plugin is extensive enough to deserve a column of its own (in fact, e-mail me at lj@greenfly.net if you'd be interested in that.)” Well, I received a number of responses, so between that and my love for all things with vi keybindings, I think it's worth giving the Vimperator plugin the full column it deserves.
As I mentioned in my previous column, the main reason I love vi-style keybindings is that they keep your fingers on the home row (the asdfghjkl; row on your keyboard)—something quite important if you touch type. Once you get used to using hjkl to navigate documents, it and the rest of the keybindings become second nature. If you touch type with any decent speed, you realize how much it slows you down to reach for the mouse or even the arrow keys—particularly for something simple like clicking a link. Now, most Web browsers have some limited way to browse a page with a keyboard, but they almost always use the arrow and Page Up and Page Down keys, all of which are pretty far from the home row.
In the past, I've used a number of methods to add some level of vi-style keybindings to Firefox. At first, I used a custom configuration to my Firefox config, and later, I used the mozless extension. Both worked okay, at least for certain versions of Firefox, but they still were a limited version of the real thing. Well, the Vimperator plugin is the real deal. It goes far beyond simple keybindings and actually creates a modal interface with an incredible level of detail. You not only get hjkl navigation, but you also can open tabs and even record macros just like in vim. What's more, Vimperator was built with Web page navigation in mind, so there are keybindings available to make it easy to click on links and even hover over elements on the page—all from the keyboard.
The first step is to install the Vimperator plugin. Visit vimperator.org, click on the Download Vimperator button on the page, and go through the typical Firefox plugin installation process. Once you start Firefox again, the first thing you will notice is that your menu bar is gone (Figure 1)! Now, this might be fine once you get accustomed to Vimperator, but I found it a little jarring at first, so you might want to type :set guioptions+=mT to turn the menu bars back on for now. Notice that as with vim, you press the : key to enter command-line mode. Vimperator turns Firefox into a modal browser like vim that has a command-line mode (accessed when you press the : key) as well as a normal and insert mode. Also as with vim, when you get stuck in some strange mode, you generally can just press Esc a few times to get back to normal. If you find you want the menu bar back permanently, add the following to your ~/.vimperatorrc file:
set guioptions+=mT
This file acts like ~/.vimrc, so you can add any other Vimperator-specific settings here as well.
The basic navigation with Vimperator should be pretty familiar to you if you've ever used vim before, but in case you are still new to that kind of navigation, here's a quick list of keybindings:
h — scroll left.
j — scroll down one line.
k — scroll up one line.
l — scroll right.
gg — move to the top of the page.
G — move to the bottom of the page.
/ — enter search mode.
n — move to the next match in your search.
N — move to the previous match.
Spacebar — move down one page.
Shift-spacebar — move up one page.
Esc — go back to standard navigation mode.
F1 — show Vimperator help.
So for instance, if I wanted to use Vimperator to search for “Sarah Conner”, I would press /, type in Sarah Conner and press Enter. Vimperator would jump to the first instance on the page. If the first Sarah Conner wasn't the right match, I would press n to move to the next match or N to go back to the previous match. If I wanted to start a new search from the top of the page, I could type gg to move back to the top, then / to enter search mode, and then type, for instance, “John Conner” and press Enter.
As with vim, you also can add numerical modifiers to any of these commands, so if you want to move down five lines instead of just one, you can press 5j. If you forget the keybinding for a particular function, just press F1 or type :help to see the full Vimperator help screen.
Vimperator would be useful even if it provided only the standard navigation keys, but it also adds a complete set of keys to access standard browsing functions. Here is a list of some of the standard ones:
H — go back in the current tab's history.
L — go forward in the current tab's history.
gt — go to the next tab.
gT — go to the previous tab.
d — close the current tab.
u — undo: open a previously closed tab (works with multiple previously closed tabs).
r — reload the current page.
R — reload the current page without the local cache.
Now, I've found that when I use tools like S5 for Web-based presentations, the keybindings it expects conflict with Vimperator. Luckily, Vimperator makes it easy to disable its keys temporarily. Simply press Ctrl-z, and all keybindings will go back to standard Firefox mode until you press Esc. I also use this mode when I browse Google Reader, because it already accepts vi-style key bindings to browse through RSS feeds. If you just need to enter one key that Vimperator won't intercept, you can press Ctrl-v, and after you press the key, Vimperator will go back to its normal mode.
Once you have the standard movement down, you might wonder, how do I actually open a new URL without a menu bar? Either press o (or type :open) followed by the URL you want to open to load that URL in your current tab, or press t (or type :tabopen) to type in a URL to open in a new tab. In addition to these basic keys, there also are a number of variations to them:
T — open a :tabopen prompt, but fill in the URL with the URL of your current tab.
O — create an :open prompt, but fill in the URL with the URL of your current tab.
w — like :tabopen but only opens the URL in a new window.
W — like T, it creates a :winopen prompt and fills out the URL with the URL in the current tab.
p — open a URL based on the contents of the clipboard.
Once you type in a URL, you also can press the Tab key to trigger Tab-complete based on your browser history. Speaking of browser history, you still can access that and the other standard Firefox functions from command-line mode:
:bmarks — access all of your Firefox bookmarks in command-line mode.
:history — view your browser history.
:emenu — access functions in the standard Firefox menu.
:dialog — access other Firefox dialog windows; type :help :dialog for more information.
Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- What's the tweeting protocol?
- New Products
- Readers' Choice Awards
- RSS Feeds
- Dart: a New Web Programming Experience
- Reply to comment | Linux Journal
11 hours 47 min ago - Reply to comment | Linux Journal
14 hours 19 min ago - Reply to comment | Linux Journal
15 hours 36 min ago - great post
16 hours 11 min ago - Google Docs
16 hours 34 min ago - Reply to comment | Linux Journal
21 hours 22 min ago - Reply to comment | Linux Journal
22 hours 9 min ago - Web Hosting IQ
23 hours 43 min ago - Thanks for taking the time to
1 day 1 hour ago - Linux is good
1 day 3 hours ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.





Comments
Hey.
Hi there. My name is ---- but my friends call me -----. I like to look at funny pictures of old people. My top three is the dancing man, the muffin lady and Karen. The dancing man is funny because he doesn't have any teeth and has a funny suit. He is also dancing a funny dance. He is very silly. I like the muffin lady because her face reminds me of blueberry muffins. And everyone likes blueberry muffins! Especially me. I love the little bits of blueberry, they are very crunchy
vimperator and "next" links
Great article. I wanted to mention that the specific example you site in your section on hinting ("For instance, if you are reading a multipage article on the Web and see links to each page of the article along with a Next link") is a poor example -- see the help for "[[" and "]]". These keybindings automatically look for next/previous links and activate them (so, when browsing multi-page articles at online magazine sites, you can simply type ']]' to move from one page to the next).