Visual Studio 2017 extended development (3) bind shortcut keys to menu items, visual Studio
How to map keyboard shortcuts to custom buttons, how to use shortcut keys to start the menu created by myself, confused at the beginning, found for a long time. It may also be because I didn't quite understand it at the beginning, and I will understand it later. It is actually very simple.
Many shortcut keys are already used in Visual studio. verify whether the shortcut keys you want to set can be used before confirming the shortcut keys. Of course, they cannot be repeated, right.
Verify that the shortcut key is used
Tools → options → environment, select the keyboard and enter the shortcut key you want to set. If the shortcut key has been used, the currently used object will be displayed.
Bind keyboard shortcuts
Open commandPackage. vsct
Add
<KeyBindings> <KeyBinding guid="guidCommandPackageCmdSet" id="CommandId" editor="guidVSStd97" key1="m" mod1="CONTROL" key2="n" mod2="CONTROL"/> </KeyBindings>
Here I set the key combination, Ctrl + m, Ctrl + n, or you can directly Ctrl + a character, then remove key2 and mod2.
In most cases, it is best not to use Shift, because it may cause uppercase or lowercase letters.
Editor = "guidVSStd97" is used to make the command available in the visual studio compiler.
Guid is the name in Symbols. Here I am
<Symbols>
<! -- This is the package guid. -->
<GuidSymbol name = "guidCommandPackageCmdSet" value = "{0ea%e5-6e5d-420c-a89c-ad63d15d521a}">
</Symbols>
Therefore, the guid here is guidCommandPackageCmdSet.
The keyBinding id is the id of the Button you set.
<Button guid = "guidCommandPackageCmdSet" id = "CommandId" priority = "0x0100" type = "Button">
So the id is CommandId
This article is my learning record. If you have any questions, please comment below. repost the article to indicate the source.
If you have any help, please give me a thumbs up at the bottom right of the mouse. Your support is my greatest motivation.