How can I set an "open with" keyboard shortcut in windows 7?

5

1

I have a shortcut to open vim, but I would like to create a shortcut to open the currently selected file in windows explorer with vim (if that is not the program associated with the file's type).

Using the shortcut for the executable opens it with no file selected.

DanB

Posted 2011-08-14T02:30:04.457

Reputation: 151

Answers

1

Works perfectly well as mentioned on microsoft's site https://answers.microsoft.com/en-us/windows/forum/windows_vista-desktop/right-click-open-with-command-missing-help-please/a9c3f139-075c-4285-b87d-25e899fb8b27

By design, the Open With menu option is not available when you right-click executable files (.cmd, .bat, .pif, .scf, .exe, .com, or .scr), or shortcuts to executable files.

If you've lost the Open With menu option for ALL file types, including non-executable files, follow this steps:

  1. Click Start, All Programs, Accesories, Notepad.

  2. Copy and paste this text:

  3. Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT*\shellex\ContextMenuHandlers\Open With] @="{09799AFB-AD67-11d1-ABCD-00C04FC30936}"

  4. Click File, Save As, name the file "OpenWith.reg" (WITH THE QUOTATION MARKS) and click OK.

  5. Now double-click OpenWith.reg, click Continue, Yes, OK, and see if the problem is solved.

Hope it helps.

Anmol Saraf

Posted 2011-08-14T02:30:04.457

Reputation: 205

1

Create an entry in HKEY_CLASSES_ROOT\*\shell

1. Right-click it and choose new key - Name it "Open with VIM"
2. Right Click the new key - choose new key - and name it "command"
3. Set that key's default value to "PathToVIM" "%1" with quotes

It is a mouse shortcut, instead of keyboard. From then on right clicking on any file with give a "Open with VIM" in its context menu.

Kevin

Posted 2011-08-14T02:30:04.457

Reputation: 1 873

0

ideally you should add the & char in the description of the verb that identifies the action you want to trigger. it is in the registry key associated to the application related to the file extension of the selected file (hum.. quite complicated) the char following the & will become your hotkey as stated in the msdn doc here

https://msdn.microsoft.com/en-us/library/windows/desktop/cc144101(v=vs.85).aspx

(of course this link explains how to do it better than I can)

Verbs can also have a display string associated with them, which is displayed on the shortcut menu instead of the verb string itself. For example, the display string for openas is Open With. Like normal menu strings, including an ampersand (&) in the display string allows keyboard selection of the command.

but (at least on windows 10 where I've tried it) it doesn't work for me, or maybe i'm doing something wrong. Unfortunately I don't have a windows 7 on hand so I cannot verify the behavior there

Mosè Bottacini

Posted 2011-08-14T02:30:04.457

Reputation: 101

Welcome to Super User! This is really a comment and not an answer to the original question. You can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. Please read Why do I need 50 reputation to comment? What can I do instead?

– DavidPostill – 2016-11-27T11:02:09.287

0

I'd do it with an AutoHotkey script like so:

SendMode Input
#SingleInstance force
^+V::
If WinActive("ahk_class CabinetWClass") or WinActive("ahk_class Progman")  ; explorer or desktop
{
  Clipboard =
  Send ^c
  ClipWait
  Run, gvim %clipboard%
}
return

This script does the following

  • Triggers when "Ctrl Shift v" is pressed
  • Copies the selected file path (among other things) to clipboard like pressing "ctrl c"
  • Runs gvim with the copied file path as an argument

You may need the full path instead of "gvim." It works on mine because gvim is on my Windows path. See this question for more on vim and system path: https://stackoverflow.com/q/17632102/2043621

Here's the gist: https://gist.github.com/OkumaTony/b0ce35e6a72e33787c869457513472fe

To be complete, you should force #SingleInstance and back up and restore the clipboard contents and a few other things but .. I'll leave that "as an exercise for the reader." =P

Still.Tony

Posted 2011-08-14T02:30:04.457

Reputation: 975

-1

  1. Right-clock the file you want to open with VIM
  2. Select "Open with"
  3. Select "Choose default program..."
  4. Browse to the VIM executable location
  5. Make sure "Always used the selected program to open this kind of file" is checked
  6. Click OK

From now on, this file type will be opened by VIM.

Traveling Tech Guy

Posted 2011-08-14T02:30:04.457

Reputation: 8 743

I don't want vim to become the new default for that file type. I just want to make it easier to open the file type with vim. For instance, I want html files to default to a browser, but I shouldn't have to search through the menus for the "open with" every time I want to open it with an editor. – DanB – 2011-08-15T04:41:52.010

Then set is as the default HTML editor in your default browser (look for instructions o how to set default applications for your preferred browser) – Traveling Tech Guy – 2011-08-15T05:34:35.913

My goal is to open any file in my editor of choice (which happens to be VIM) with a keystroke-combination. I only gave html as an example, but I don't understand how setting my editor in the browser achieves that goal even for html files. – DanB – 2011-08-15T13:05:52.853