[Vim tips] How to Control Firefox using Vim keybindings

Source: Internet
Author: User

How to Control Firefox using Vim keybindings by Joe 'zonker' brockmeier
On
June 22,200 (5:00:00)


Share
Print
Comments

Vim
Users stick with vim in no small part because muscle memory is so
Powerful -- once you 've learned Vim's keybindings, it's possible to be
Extremely productive in VIM without ever taking your hands off
Keyboard. If you 'd like to imbue Firefox with vim power, embrace the vimperator extension. vimperator turns Firefox into a no-nonsense, modal web browser.

The vimperator 0.4.1 extension is available on paidev.org.
To install the extension you can download it to your hard drive or just
Click on the most recent version. You may need to add the site to your
Allowed List of sites for installing extensions. Firefox will display
Bar at the top of the page if the site isn't on the allowed list --
Just follow the prompts.

When you restart firefox after installing vimperator, you'll notice
That its menu bar, location bar, And the status bar have disappeared.
Vimperator replaces the default status bar with a custom Status Bar
That shows the command line and the current URL, and an indicator that
Shows what tab you're in and where you're at in relation to the length
Of the page. For instance, if you have five tabs open and you're
Viewing the second tab, the status bar will display[2/5]. If you're at the top of the page, it will displayTop, OrBotAt the bottom of the page. If you're at some spot in the middle, it will display an approximate percentage.

What if you just can't live without one of the Firefox toolbars that
Vimperator hides? No problem. As in Vim, you can enter commands in
Vimperator's "last line mode" by typing:And the command. to modifyguioptionsSettings and make the location and Menu Bars visible, type this command, then press Enter:

:set guioptions=mT

You shoshould see the location bar (T) And menu bar (m) Again. To bring back the bookmark bar, you cocould addb, AndsFor the original firefox status bar.

Navigation

Vim and VI users will take to most of the vimperator mappings right
Away. The Standard VI/Vim movement keys work as you 'd expect CT:kMoves up,jMoves down,hMoves to the right, andlMoves to the left. to scroll to the top of the page, usegg, And to move to the end of the page, useG.

If you go to a page, like Google, that puts the cursor in a text
Field, you'll be in insert mode rather than command mode. In that case,
If you try to use navigation keys or start a search, you'll just end up
Typing text in the text field. You can pressTabTo move the cursor from the text field, orEscTo move into command mode.

What about browsing? Vimperator has a full set of commands that will
Help you navigate from the keyboard almost effortlessly. I won't
Reproduce the entire list, but here's a sample to get you started:

  • gtOrCtrl-n: Go to the next tab.
  • gTOrCtrl-p: Go to the previous tab.
  • gh: Go to your home page.
  • gH: Go to your home page, in a new tab.
  • gu: Go up. For example, wocould take you from http://www.example.com/blog/ to http://www.example.com /.
  • H: Go to the previous page in your browser history.
  • L: Go to the next page in your browser history.
  • :o http://www.example.com/: Open http://www.example.com /.
  • :o search term: Use the default search engine to search for a search term.
  • :o filename: Open a local file using Firefox.
  • :q: Close the current tab. If only one tab is open, exit Firefox.
  • zi: Zoom in. Increases text size by 25% on the page that has focus.
  • zI: Zoom in by 100% on the page that has focus.
  • zo: Zoom out. Decreases text size by 25% on the page that has focus.
  • zO: Zoom out by 100% on the page that has focus.
  • zz: Used alonezz
    Will reset the page to 100%. Used with a count, it will set the text
    Size to any value between 25% and 500%. So, 105zz will set the text
    Size to 105% of normal.

Vimperator also sports a few hint modes, where links have a yellow
Label containing a shortcut cut to use the link. This is much like Konqueror's feature for keyboard navigation.

To enter quickhint mode, pressf. Each link shocould have
A label, and you can activate the link by entering its shortcut. So, if
You're on a page with a dozen or so links, you'll have hints labeled,
B, c, d, etc. If you pressa, You'll browse to that link. If you pressA, The link will be opened in a new tab in the background.

But wait, there's more! You can also use;To enter
What's called an extendedhint mode. You'll see the same labels,
When you enter the shortcut, you'll just highlight the label. Once
You 've selected a link, you can useyTo copy the URL, orYTo copy the text description of the URL.

Browsing with vimperator

One of vimperator's most powerful features is the way it lets you handle Firefox history. If you use:historyCommand, it will pull up the most recent 10 pages you 've got browsed. This includes des local files as well as regular pages.

The default for history is to bring up only 10 pages, which isn' t
Too useful if you're Looking for something from two days ago. You can
Combine:historyWith a search term to find URLs or page
Names that match what you're Looking for. Let's say you're trying
Find pages you 've ve browsed with "Craigslist" in the title or URL. Use:history craigslist
And vimperator will display a preview window at the bottom of
Browser window with the most recent 10 pages that match "Craigslist" in
The title or URL.

To browse to a page, double-click on the history entry you want in
The preview window. (Yes, right now there's no way to get there from
The keyboard.) to close the search result, Type:pc, Or:pclose, If that's easier to remember.

What about using bookmarks? To add a bookmark, use:bmaddCommand, and use:bmdel urlTo delete a bookmark. You need to be very specific when you're using:mbdel, As it will delete any bookmarks that match a URL.

The:bmCommand displays bookmarks. Use:bm!To open a page with all the bookmarks displayed, and a search bar at the top of the page. According to the help text,:bm expression
Shocould allow you to search through your bookmarks, but this just
Returns an error for me, so I suspect it's not fully implemented yet.

Searching

In Firefox,Ctrl-fPops open the Search dialog near the status bar. Using vimperator,Ctrl-fWorks as it wocould in VIM -- it moves you one "page" forward. The standard Vim search mapping,/, Works in vimperator -- though the Backward Search mapping (?) Is not recognized.

Once you 've entered a search term, you'll be taken to its first instance (if there is one). Unlike in Vim, you'll need to pressEscTo escape from the search field. To look for more instances of a search term, usenTo move forward through the search, andNTo move backward.

The search term is applied when SS all tabs, So if you search for XYZ in your first tab, and then usegtTo move to your second tab, you can still search that page for the same search term.

Getting help

Just as in Vim, You can get help for vimperator by typing:helpAt any time. This command will bring up a local copy of The vimperator help document, which covers all the options, mappings, and commands that are used with vimperator.

You can also, in some cases, go straight to the help for a specific
Mapping. For example, if you want to see the reference for:openCommand, use:help :open.
The problem with this is that you need to know the command you want
Use. It's fine as a reference, but not so good if you're not sure what
Command to use to do something.

Quitting

When you're ready to exit Firefox, you can do so in a number of ways -- just as you can in Vim. Using:qWill exit Firefox if you're on the last tab. Otherwise, it closes the tab you're in.

Using:qallOrZQWill exit Firefox and
Clear the session history. If you want to quit Firefox, but restart it
Later with the same session, you can useZZInstead.

If you want to restart Firefox immediately, you can use:restartCommand.

Setting options

We 've already covered using:setTo change some of vimperator's options. The vimperator help document should des a full list of options that can be set.

You can also set your defaults using a configuration file. To Do
This, create a file called. vimperatorrc under your home directory.
Vimperator will check for this when it starts. The advantage to using
Configuration file is that it can reset options when Firefox starts.
For instance, if you don't like having the Firefox toolbar open, you
Can set that in your. vimperatorrc and make sure it's not open when you
Restart Firefox -- even if you had opened it during a previous session.

What you can and can't do with vimperator's configuration file isn't well-formed ented yet, but you can use an example Vim syntax configuration that provides syntax highlighting for editing. vimperatorrc file. vimperator's developer, Martin stubenschrott, has indicated
That users shoshould wait for vimperator 0.5 to do any scripting, as he's
Planning to change and document the API at that time. You shoshould also
Be able to use:mapFunctions at that time.

Playing nice with others

Vimperator is an excellent extension, but it doesn't play well
All of Firefox's features or extensions at this time, or with web sites
That have navigation keys that conflict with vimperator's mappings.

For example, when using vimperator, The subscribe feed button in
Location bar doesn't seem to work, even when the location bar is set
Be visible usingguioptions. This is also true of the reload button, which is grayed out with vimperator enabled. The default Firefox shortcut cut for reload,F5, Does not work, though you can user
To refresh the page. Unfortunately, vimperator doesn' t have a shortcut cut
For the subscrifeature, so it's not possible to easily subscribe
To a new feed using Firefox's subscribe feature while vimperator is
Running.

Since vimperator hides the default status bar, any extensions that
Utilize the status bar are also affected. Google's notebook extension,
For instance, is not disabled, but you can't open the notebook
Clicking the notebook icon in the status bar. You can open it from
Firefox context menu if you use the note this menu entry to add a note
-- The Google notebook pop-up will still work fine, It just doesn' t
Have a button in the status bar. Note that you can restore the default
Firefox status bar using:set guioptions=sAnd it will appear on top of the vimperator status bar.

Occasionally, vimperator also conflicts with keybindings set by
Web page. I thought, briefly, that I wowould have to choose
Google Reader and vimperator, because the navigation keys
Vimperator and Google Reader conflict. However, vimperator has
Solution for keybinding conflicts. You can pressITo ignore vimperator's keybindings, andEsc
When you're ready to re-enter vimperator mode. This doesn' t fix
Glitches like the subscribe button, but at least it lets you use
Applications like the feed reader without having to uninstall or
Disable vimperator.

In general, vimperator's vi-like mappings integrate surprisingly
Well with Firefox. for hard-core Vim junkies who hate having to use
Mouse success t when absolutely necessary, vimperator makes Firefox more
Enjoyable.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.