Skip navigation

Lost password? | Help

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 4. July 2008, 05:03

This could be a good default :wink:

Tamil 4. July 2008, 05:11

:up:

Change

<a href="./vimperator-for-opera#download">Download</a>

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

Blazeix 6. July 2008, 02:10

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 6. July 2008, 05:39

Originally posted by Blazeix:

both ways seem to work under Opera

:yes: but first one relods page.

mksdcom 7. July 2008, 11:12

Hi,Blazeix.
Hit-a-hint spacial navigation is a NICE CODE!:D
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 7. July 2008, 16:46

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

edvakf 27. July 2008, 17:56

kurt duyck 2. October 2008, 21:59

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

edvakf 3. October 2008, 06:09

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@h3k 29. November 2008, 09:13

good job.

dabbish 1. December 2008, 16:27

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 9. December 2008, 10:18

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 10. December 2008, 20:04

@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 12. December 2008, 23:19

It worked. Great thing. Thank you very much.

josef behr 5. January 2009, 10:01

fucking great :smile: i love it. i never used vimperator, though, but wanted a slim and customized opera, which i can control solely via keyboard. after adding a few keybindings, it fits my needs perfectly. thanks :D

Rasmus Steinke 25. January 2009, 00:43

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

Rasmus Steinke 25. January 2009, 04:14

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 25. January 2009, 13:11

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 duyck 29. January 2009, 13:52

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 5. February 2009, 14:12

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

Blazeix 1. March 2009, 04:37

@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 12. March 2009, 00:47

Awesome Blazeix, thanks!

Nick 30. March 2009, 11:30

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 31. March 2009, 12:52

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 16. April 2009, 09:06

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).

Rasmus Steinke 2. May 2009, 13:54

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

jabu2oz 11. May 2009, 23:15

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 7. August 2009, 14:21

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 25. November 2009, 10:13

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.

Write a comment

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

December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31