Here’s a quick tip for Opera and Vim users: How to add a menu item which allows you to quickly open highlighted text on a web page in Vim.
This trick can be applied with any other application too, like <insert your favorite editor>
Step 1: Create copy of the standard menu configuration
First, you need to create a copy of the standard menu configuration so you can go back if something goes wrong.
This can be achieved by going to preferences (Ctrl+F12), Advanced, Toolbars. Now choose “Opera Standard” from under “Menu Setup”, hit Duplicate and then click on the newly duplicated setup. Hit OK and you’re done with this step
Step 2: Edit menu configuration
Now, you need to find the menu configuration file. It’s located in the directory where Opera stores your profile – typically in Documents and Settings, but the easiest way to find it is by going to opera:about.
The path to your profile is displayed under “Paths”, as shown below:
In my case the profile directory is the one highlighted in the image. Find yours, and you should see a directory called Menu under it.
In the menu dir, you should have a file called standard_menu (1).ini. Open it and find the line which says Hotclick Popup Menu
Under it, you should see lines such as “Item, M_COPY_TO_NOTE=Copy to note”
To add a new Copy to Vim item, insert the following line:
Item, Copy to Vim = Go to page, “data:text/open-in-vim,%t”
Here we are essentially adding a new command to go to a specific URL. In this case, it’s a Data URI, using mime-type text/open-in-vim, which is something we made up, and then including the text highlighted with the identifier %t
Step 3: Add new mime-type handler
Now that we have modified the menu configuration, the last thing we need to do is add a handler for our own text/open-in-vim mime-type.
Go back to Opera’s preferences, but this time choose Advanced, Downloads.
Click on Add… and fill in the dialog:
Extension: openinvim (this can be anything you want actually)
Action: Open in Other Application, fill in path to vim’s executable.
If you didn’t restart Opera yet, do that now. You should now get a new Copy to Vim menu option whenever you highlight text and right click.