Blazeix's Blog

Opera stuff

Vimperator for Opera

, , ,

Introduction

One of the best extensions out there for Firefox (in my opinion, at least) is Vimperator. Quoting from the Vimperator index page, "Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor." I and many of my friends have installed Vimperator, and immediately became addicted to it. It sped up workflow and was fun at the same time. Vimperator is the main reason why I stuck with Firefox so long before switching to Opera.

A while ago I decided to test out Opera, figuring that I'd eventually switch back to Vimperator. Before I switched back, however, I took a look at the versatile keybindings and customization available. I was so impressed I decided to stick with Opera, and recreate the Vimperator functionality. I've emulated some of the features I use the most in vimperator, including common keybindings and the Hit-a-Hint navigation. I've uploaded my configuration to this post, so you can enjoy Vimperator navigation with the speed of Opera.

Installation

To make Opera 9.51 behave like Vim, and by extension Vimperator, follow these instructions:

  1. Download the attached file 'vimperopera.ini' (see bottom of post) and place it in your profile under the 'keyboard' directory. Under Linux, this directory is under:
    ~/.opera/keyboard
    For Windows, look under
    C:\Documents and Settings\user\Application Data\Opera\Opera\profile\keyboard
  2. Open up your preferences window and navigate to Advanced->Shortcuts->Keyboard Setup and choose 'vimperopera'. Press O.K.
  3. (Optional) To get a more authentic Vim[perator] experience, you may want to hide all of your toolbars except for the tab bar and address bar. Do this from the Tools->Appearance->Toolbars tab, and press Shift+m to toggle the menu bar on/off. I put my address bar at the bottom of the window, and kept the tab bar at the top. I hid all the other toolbars.
Using Vimperopera

Now, vim and vimperator are modal programs and Opera, well, not so much. However, I feel very comfortable using the vimperopera keybindings and can switch back and forth between vimperator and vimperopera with ease. Almost all of your trusty vimperator keybindings are available (At least, the ones that I could find mentioned in the Vimperator documentation, which seems to be lacking). All the shortcuts I've grown attached to such as gh (go to homepage), gH (go to homepage in new tab), o, O, t, T, etc. are all working. See the list below for the keybindings.

As I mentioned earlier, hit-a-hint spacial navigation, which I can't live without, has been emulated using Javascript bound to the 'f' key for basic hints and ';' for extended hints.

  • Basic hints ('f') - Displays numbers next to each link. Type the number of link and press enter to go to that link. If the number you type has only one possible hint, that hint will be automatically chosen for you.
  • Extended hint mode (';') - Displays numbers next to each link, and allows you to open multiple links at a time. Type in the numbers of the links you want to follow, separated by a comma, and press enter when you are done. Those links will open in new tabs.

Screenshot of Vimperopera in hints mode

Additional Approvements
  • I found that the Opera Standard Slim Skin, by Tamil, fits well with the whole Vim look. It's a minimalistic skin that decreases the padding of the default Opera skin.
  • I use google bookmarks, so I bound ':' to 'focus address bar', nicknamed the google bookmarks page 'bmarks', and the 'Add to bookmarks' bookmarklet 'bmark'. Now, when I type ':bmarks' and ':bmark' I get a list of bookmarks and a prompt to 'Add page to bookmarks,' respectively.
  • I also dislike how google automatically steals focus for its search bar, so I added the 'blurgoogle' UserJS, see attached.
Hotkeys

Here are a list of the hotkeys available with this keybinding. This list omits the default keybindings for brevity.

Key Combo Description
shift m Toggle Menubar
h move left
j move down
k move up
l move right
H Back
Ctrl o Back
L Forward
Ctrl i Forward
gh go to homepage
gH go to homepage in new tab
gt next tab
gT previous tab
d delete (close) tab
o address bar
O address bar with current url
t new tab
T new tab with current url
gu go up one level
u undo close tab
y yank (copy) current address on to clipboard
p paste clipboard contents
P paste clipboard contents into new tab
i focus first form field
gi focus previous form field
[[ Rewind
]] Fast forward
r refresh page
/ find
n find next
N find previous
Ctrl Insert Copy
Shift Insert Paste
zi zoom in
zo zoom out
wq hide opera
ZZ quit opera
e open xterm
Ctrl q, dw delete a word in a text field
Ctrl q, dd clear a text field
Ctrl q, d$ delete to end of line
b bookmark
ctrl b bookmark list
m mail
: focus address bar
f hints mode
; extended hints mode


Download

vimperopera.ini - Keyboard Configuration

blurgoogle.js - Optional BlurGoogle UserJS


Credits and Changes
  • A big thanks to Calmar's Opera keybindings, which served as an excellent starting point!
  • mksdcom let me know about the e.preventDefault() call, thanks! I've updated vimperopera.ini to call this function.
  • 7/7/08 - Made extended hint mode more robust
  • 2/28/09 - Made normal hint mode open in current page, like FF's vimperator does. Added Page[Down,Up], Home/End, and Ctrl[+shift]+Tab key bindings due to popular request.

Comments

Moose Friday, July 4, 2008 5:03:01 AM

This could be a good default wink

Tamil Friday, July 4, 2008 5:11:32 AM

up

Change

Download

to
<a href="#download">Download</a>

Blazeix Sunday, July 6, 2008 2:10:36 AM

Tamil, both ways seem to work under Opera, but I've changed it just in case there are compatibility issues elsewhere. Thanks for the skin!

Tamil Sunday, July 6, 2008 5:39:43 AM

Originally posted by Blazeix:

both ways seem to work under Opera

yes but first one relods page.

mksdcom Monday, July 7, 2008 11:12:40 AM

Hi,Blazeix.
Hit-a-hint spacial navigation is a NICE CODE!bigsmile
So,I add some code,"e.preventDefault();" in interpretKeyStroke function.
The code passed Opera's default key event.
Please visit my page,and reading my code.smile
http://looxu.blogspot.com/2008/07/blog-post_07.html
Thanks!

Blazeix Monday, July 7, 2008 4:46:54 PM

mksdcom, thanks for the tip! I've updated my post (see Credits & Changes section)

edvakf Sunday, July 27, 2008 5:56:29 PM

kurt duyckiland Thursday, October 2, 2008 9:59:42 PM

thanks a lot for this. you made my day. good vibes 2 U.

edvakf Friday, October 3, 2008 6:09:59 AM

I found a minor bug, in the extended hint mode,where if your "choices" array is empty, backspace doesn't work.

This part of the code;
if(key=='Bkspc'){
  if(choices.length){
    if(choice!=''){
      choice='';
    }else{
      hintlist[choices.pop()].style.backgroundColor=bgcolor;document.title=originalTitle+' - '+choices.join(',');
    }
  }
}


should be something like this (*I haven't tested this*)

if(key=='Bkspc'){
  if(choice!=''){
    choice='';
  }else{
    if(choices.length){
      hintlist[choices.pop()].style.backgroundColor=bgcolor;
    }
  }
  document.title=originalTitle+' - '+choices.join(',');
}

z@h3kZAHEK Saturday, November 29, 2008 9:13:56 AM

good job.

dabbish Monday, December 1, 2008 4:27:58 PM

Ok great stuff but how do I make the links in to numbers as I can with vimperator? Do I still have to use the mouse to click on links?

poisson Tuesday, December 9, 2008 10:18:59 AM

Thank you for these great shortcuts!
Just a question: I would like "f" to open links in the current page, and not in a new one. Is this possible?

Blazeix Wednesday, December 10, 2008 8:04:07 PM

@poisson: that is possible, in the ini file that you download, just replace the window.open(XXXX) calls with location.href=XXXX, where XXXX is whatever is in the parentheses

poisson Friday, December 12, 2008 11:19:38 PM

It worked. Great thing. Thank you very much.

blubrasi Sunday, January 25, 2009 12:43:16 AM

with this keyboard.ini loaded my pageup, pagedown, home, end keys stopped working... sadly espacally those are handy in keyboard navigation smile

blubrasi Sunday, January 25, 2009 4:14:04 AM

And another thing: When opening the bookmarks, i cant get out of it without the mouse... because the "d" key wont close it. ctrl-F4 probably would work, but thats a global hotkey here smile

dabbish Sunday, January 25, 2009 1:11:52 PM

i would like to see pageup, pagedown, home, end keys working too. also would be good to get ctrl + tab and ctrl + shift + tab working as well.
awesome plug-in though smile

you can do space for down, and gg for home

kurt duyckiland Thursday, January 29, 2009 1:52:50 PM

about 'f' loading links in the current page:
" just replace the window.open(XXXX) calls with location.href=XXXX, where XXXX is whatever is in the parentheses" did not work for me. however it also works with window.open(getURLchoice(),'_self');

dabbish Thursday, February 5, 2009 2:12:21 PM

i am willing to pay to get some things working. pls email me if interested: dab214 no spam at yahoo dot com

Blazeix Sunday, March 1, 2009 4:37:25 AM

@dabbish, I made an update that will add the keybindings you requested. No need for pay, it was easy to add in.

As the change log states, I also made it so 'normal hints mode' opens the link in the current window by default. This works on my computer. iland had trouble with manually putting in the change, but hopefully that was user error and this update will work for everybody.

dabbish Thursday, March 12, 2009 12:47:53 AM

Awesome Blazeix, thanks!

NickPadeenC Monday, March 30, 2009 11:30:09 AM

This is the best opera tip/addon/extension I use. It's great. Thanks. I use it on all my boxes, Linux, BSD and Windows.

Here is my request (we all get one request, don't we? :) )

If you work in technology or research you often want to restrict your google searches to fairly recent information. I have my own search set up that is the google one, but with the addition of restricting the date of the page to the last year using the google advanced search's URL.

However, often you want to switch between the date-restricted search and the normal search, when you realise you want older info, or more recent info, etc. Something I find really useful is the ability to change the google search URL to change some date restrictions. So I have F5 set to: 'go to page,"%u&as_qdr=y"', which changes the existing search to less than 1 year filter, plus adds the google date restriction drop-down box (Google adds this automatically when you use a date filter). You can use the drop-down box to alter your date filter.

BTW, I'm guessing the '&as_qdr=y' parameter decodes as '&AdvancedSearch_QueryDateRestriction=Year'.

You can change the URL parameter string from the default of &as_qdr=y to &as_qdr=Xy, where X is a number of years, and you can change the time frame from 'y' to 'm' or 'd', although google may in fact return results that conform more closely to their inbuilt date ranges. It's still very useful though. Also, changing the parameter away from Google's defaults removes the drop-down box. Page-back returns it.

Ok, enough of the explanation. What I'd like is some way to change the shortcut so that it opens in the same tab rather than opens the new one that 'go to page' does.

More advanced, it would be really useful for some javascript tied to another key that pops up a message box where you can enter something like one of 'y', '3y', 'm', '3m', '7d', 'd' and so on, which is then appended as the date restriction. This would be much more useful than the current functionality of defaulting to one year, and then you have to change it manually yourself.

Phew, after that spiel, I need my own blog page. Thanks again,

Nick.

shkm Tuesday, March 31, 2009 12:52:49 PM

Wow! Just came back to opera after having tried a bunch of different browsers. Tried to get away from Firefox as it just feels slow. Safari also has some kind of vim implementation available, but it's poorly done (due to limitations, most likely). What you've managed to pull off using only Opera's basic functionality and a little JavaScript snippet is phenomenal.

I believe this truly shows off the power of Opera--it may not have true addons like Firefox, but you can do so much without them.

Many thanks for your work!

tabanhachi Thursday, April 16, 2009 9:06:30 AM

Hi Blazeix,

I was wondering if it might be possible to implement hit-a-hint giving access to search fields as well (in addition to links).

blubrasi Saturday, May 2, 2009 1:54:44 PM

on www.doom9.org the 'f' key is not working

jabu2oz Monday, May 11, 2009 11:15:20 PM

On the basic hints script, could you add a:

"Shift+Enter" - open link in background tab function?

I had a go with:

window.open(...); self.focus();
with no avail. Perhaps an Opera specific function will do it?

Also, are there any issues with javascript on secure pages?

edit: edvakf's Hit-a-hint generator seems to do the job.

Vigil Friday, August 7, 2009 2:21:45 PM

You have to add "F2 shift=Go to nickname" into the [Application] section, otherwise it doesn't work.

Also F4, 'a ctrl', 'Enter ctrl', 'Platform Unix-Mac, q ctrl', etc. It appears that vimperopera not only adds shortcuts but takes some useful ones away, too...

Alorian Wednesday, November 25, 2009 10:13:41 AM

Blazeix, thanks for your job, but I'm think that you need to save compatibility with native opera shortcuts andf not delete them even if their functions are duplicate yours.

If you do this, your set of shortcuts will be much better.

Carson Firecarsonfire Thursday, March 4, 2010 4:38:34 PM

I never bothered learning Opera's shortcuts, but started typing hjkl in my sleep after learning Vim. Thanks for this! I use it all the time. I try to never touch the mouse anymore if I can help it, saving me a lot of, er, finger strain. bigsmile

srunni Saturday, March 13, 2010 11:37:34 PM

Do you think you could update it to work with Opera 10.50? Some of the shortcuts (such as 'd' to close a tab) don't work on a blank tab, because you can't hit escape to "exit" edit mode for the location bar.

Ramón Solísramonusky Sunday, April 18, 2010 6:59:15 AM

It's ok that the file cuts in line...

409 [Bookmarks Panel]
410 d=close window

¿?

If anyone has the complete file, please... i've been looking for days and still nothing =(

kurt duyckiland Wednesday, May 5, 2010 1:50:10 PM

type "to" in the addressbar to crash Opera 10.51 on win7. Maybe because this tries to open new tab and focus on addressbar at the same... however still great fan of the vimperator. Kind regards

kurt duyckiland Thursday, May 6, 2010 10:51:59 PM

after upgrade to 10.53 on os X 10.4 Opera refused to launch. reinstall does not help, unless i remove the vimperator.ini from the keyboard directory. reinstall and launch. then i can load vimperator again by adding to the keyboard dir. Maybe i'll have to wait for an update?
kindest regards

Michaelpurgat0ri Friday, July 9, 2010 10:36:53 AM

An update for 10.60 would be kinda nice p

kurt duyckiland Friday, July 9, 2010 9:12:02 PM

running vimperator fine on Opera 10.60 on Win and osX. My mentioned problems came with O 10.60 on os X 10.4 in general: see forum topic http://my.opera.com/community/forums/topic.dml?id=613312 . Installing Opera in a subfolder of Applications did the trick to install the latest version.

Michaelpurgat0ri Saturday, July 10, 2010 7:15:26 PM

It generally works ok for me as well, except for the address bar focus problem you mentioned.

Kurtosis Wednesday, August 18, 2010 6:27:06 AM

Doesn't look like Blaze is monitoring this thread anymore, or updating vimperopera. So I've taken the liberty of posting vimperopera to my GitHub account here:

http://github.com/byrongibson/vimperopera

Hopefully work will continue on it. Firefox, Chrom/ium all have Vim addons, Opera needs a good one too, and Vimperopera is the best one available (there's also Vopera at GitHub, but it's not going anywhere. Read the README on its GitHub page for a wtf).

Blaze if you ever read this and want to take over hosting Vimperator on GitHub, I will be more than glad to turn it back over to you, just PM me at GitHub.

Michaelpurgat0ri Thursday, August 19, 2010 1:26:33 PM

Good initiative, Kurtosis.

Michaelpurgat0ri Sunday, November 7, 2010 5:01:06 AM

I'm thinking that with the new extension API in Opera 11, it should be possible to port Vimperator or the Vim-like-ui extensions from Chrome over to Opera now.

Michaelpurgat0ri Wednesday, November 24, 2010 12:02:04 AM

I recommend that anyone who wants to keep using Vimperopera NOT upgrade to Opera 11, as it has dropped support for key-sequence shortcuts, i.e: g,t, g,g, etc. will no longer work. I also recommend that you complain to the Opera devs about this, in order to get this feature reinstated.

wang-dawei Thursday, November 25, 2010 6:35:20 AM

agreed, opera 11 no longer supports key-sequence shortcuts, which closes the door to customizing key binding. we should let opera know we still need it.

Vijay Kaulgogobera Tuesday, December 7, 2010 3:10:05 PM

I need a bit of guidance: Where does the .ini go under OS X?

bkolada Saturday, December 11, 2010 6:25:38 PM

hmm i think vimOperator sounds better

Johnny Englishdumblob Saturday, December 18, 2010 11:33:33 AM

The problem with key-sequence shortcuts (gt, gT ...) in opera 11.0 will be fixed.
See this post http://my.opera.com/community/forums/findpost.pl?id=8005242

I'm so happy - but the awaiting beats me sad.

Michaelpurgat0ri Wednesday, January 19, 2011 9:21:35 PM

Fixed in latest 11.01 snapshot smile

Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig Friday, April 15, 2011 10:45:43 AM

That is absolutely great, thank you so much

Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig Saturday, April 16, 2011 12:22:10 PM

There's also Hit-a-hint extension for Opera

plumm Sunday, June 26, 2011 3:02:55 AM

I have changed the mapping 'e' from "xterm" to "x-terminal-emulator" in the vimperopera.ini file. The default xterm opens a very small window with illegible font, the emulator loads much nicer fonts and the window size is much more useful. Otherwise you have to pass additional arguments to make the xterm useful.

Шуйский Николай [krigstask, Ŝtérkrìg]Sterkrig Monday, June 27, 2011 8:41:12 AM

plumm
Actually you just have to configure your terminal, being it xterm, urxvt or anything. And `x-terminal-emulator` is Debian/Ubuntu-specific.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.