Because Sergey asked...

Update: There is actually a bug in Beta1 and all of the current CTP’s where commands and keybindings for VSIP packages do not show up in the UI unless the user chooses the General Settings option. This bug has been fixed. The fix will be in Beta 2 Community Test Preview or CTP (expected in Feb I think) and available then at the MSDN site.

Sergey asked:

Here's how I support keyboard bindings in VS.NET 2003: 1 - assign shortcuts to most of my package 20+ commands, and 2 - provide one custom installable mapping scheme to work around a problem of shortcuts not being assigned for few commands (probably reserved shortcuts for VS internal use), and one other scheme that matches Borland Delphi shortcut assignment.

Now, in December CTP build, it seems that package commands shortcuts are only used if General Options scheme is chosen (profile?). I may be off with the exact name as I don't have Whidbey installed here. I'd like to know if there is a way to perhaps have command shortcuts be always assigned. It also seems that former .vsk files have been superseded by some sort of new global settings files, which also covers shortcuts.

To summarize, we are interested in: 1 - a consistent way of merging package shortcuts regardless of startup options chosen, and 2 - an ability to distribute custom keyboard schemes. If there are any package new registry entries to accommodate request 1, or anything to help with request 2, those are the kinds of things I'd like to see shared us.

We answer:

When you select a collection of settings the first time you launch Visual Studio, a set of keyboard shortcuts is applied to the environment. Depending on which setting you select, the keyboard shortcuts are very different. For example:

VB Development Settings

VB 6 keyboard shortcuts

Web, J# and General Development Settings

Similar to VS 2002/2003 keyboard shortcuts

VC Development Settings

VC 2 keyboard shortcuts

C# Development Settings

New set of keyboard shortcuts

The set of keyboard shortcuts that you add in your package gets added to the Visual Studio environment *before* the above keyboard shortcuts are applied. So if there are any conflicts, the shortcuts from your package will be removed. This is probably the reason why you think that only selecting General Development Settings allow you to add shortcuts because in the other cases, your keyboard shortcuts got overwritten.

To create your own custom installable mapping, you probably would want to create a .vsk file and drop it into D:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ for it to show up under Tools>Options>Keyboard.

To create a .vsk file, you need to author an .vssettings file and import it. An example is attached below:

<UserSettings>

      <ApplicationIdentity version="8.0.40218.0" name="Microsoft Development Environment" />

      <Category name="Environment_Group" RegisteredName="Environment_Group">

            <Category name="Environment_KeyBindings" Category="{F09035F1-80D2-4312-8EC4-4D354A4BCB4C}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_KeyBindings">

                  <KeyboardShortcuts Version="8.0">

                        <ShortcutsSchemeDef Name="NewKeyboardShortcuts">

                              <Shortcut Command="View.ViewCode" Scope="Global">Ctrl+Alt+0</Shortcut>

                              <!--<Shortcut Command="View.CallBrowserCallsFrom" Scope="Global">Ctrl+Shift+B</Shortcut> -->

                              <Shortcut Command="View.PreviousTask" Scope="Global">Shift+F4</Shortcut>

                              <Shortcut Command="Window.NextDocumentWindow" Scope="Global">Ctrl+Tab</Shortcut>

                              <Shortcut Command="Window.Windows" Scope="Text Editor">Alt+B</Shortcut>

                        </ShortcutsSchemeDef>

                        <ScopeDefinitions>

                              <Scope Name="Class Diagram" ID="{59B0B277-7DDF-4E36-A3ED-02DAC5B9E2FA}" />

                              <Scope Name="Deployment Diagram" ID="{D056D361-43FC-4DDD-8559-0D40EB8C77D7}" />

                              <Scope Name="Logical Datacenter Diagram" ID="{222AC579-87F1-44CE-AE8C-B7D95931ED9F}" />

                              <Scope Name="Application Connection Diagram" ID="{5A1FF380-5684-4D47-8E04-BDED2D53DCA4}" />

                              <Scope Name="{FB87333B-16C8-400E-BC8F-F6B890410582}" ID="{FB87333B-16C8-400E-BC8F-F6B890410582}" />

                              <Scope Name="XML Editor Data View" ID="{F482F8AF-1E66-4760-919E-964707265994}" />

                              <Scope Name="XML Editor Schema View" ID="{E6631B5B-2EAB-41E8-82FD-6469645C76C9}" />

                              <Scope Name="HTML Editor Source View" ID="{CB3FCFEB-03DF-11D1-81D2-00A0C91BBEE3}" />

                              <Scope Name="Managed Resources Editor" ID="{FEA4DCC9-3645-44CD-92E7-84B55A16465C}" />

                              <Scope Name="DataSet Editor" ID="{B334A759-F450-40A5-BE2A-65937BCD5415}" />

                              <Scope Name="HTML Editor Design View" ID="{CB3FCFEA-03DF-11D1-81D2-00A0C91BBEE3}" />

                              <Scope Name="Windows Forms Designer" ID="{BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F}" />

                              <Scope Name="{28D4A6C1-6FBF-42A9-8CC7-A705F524AEC8}" ID="{28D4A6C1-6FBF-42A9-8CC7-A705F524AEC8}" />

                              <Scope Name="TOC Editor" ID="{75DC5041-469F-11D3-8F04-00C04F5E0C38}" />

                              <Scope Name="Text Editor" ID="{8B382828-6202-11D1-8870-0000F87579D2}" />

                              <Scope Name="{F17BDAE0-A16D-11D0-9F04-00A0C911004F}" ID="{F17BDAE0-A16D-11D0-9F04-00A0C911004F}" />

                              <Scope Name="WebBrowser" ID="{E8B06F41-6D01-11D2-AA7D-00C04F990343}" />

                              <Scope Name="View Designer" ID="{B968E165-98E0-41F0-8FBE-A8ED1D246A90}" />

                              <Scope Name="Query Designer" ID="{B2C40B32-3A37-4CA9-97B9-FA44248B69FF}" />

                              <Scope Name="VC Accelerator Editor" ID="{EB56D0B5-BEE7-4D0C-8BE6-88A8ED256695}" />

                              <Scope Name="VC String Editor" ID="{58442DA9-10DA-4AA9-A2AF-96E4D481379B}" />

                              <Scope Name="VC Image Editor" ID="{C0BA70ED-069E-412B-9C06-7442E28A11B9}" />

                              <Scope Name="VC Dialog Editor" ID="{543E0C02-8C85-4E43-933A-5EF320E3431F}" />

                              <Scope Name="Global" ID="{5EFC7975-14BC-11CF-9B2B-00AA00573819}" />

                        </ScopeDefinitions>

                  </KeyboardShortcuts>

            </Category>

      </Category>

</UserSettings>

You should modify the section highlighted in yellow to add your keyboard shortcuts. When you are done modifying, save the above snippet into a .vssettings file and import the file via Tools>Options>Import and Export Settings. When you are done importing, you will have created a new .vsk file under c:\Documents and Settings\<username>\Application Data\Microsoft\VisualStudio\8.0\ called "NewKeyboardShortcuts.vsk".

Important note: This material is provided in an 'as is' condition so that you might evaluate it for your own use at your own risk. You agree that by providing comments, suggestions, or other feedback related to our products, technology or services to the individuals listed above, you allow Microsoft, at its option, to use your feedback in our products, technology, and services without any obligation to you. Due to the volume of e-mails we receive, Microsoft, including the individual listed above, may not be able respond to your e-mail.