Click here to Skip to main content
14,550,550 members

SSMSKeyBindings - edit keybindings in sql mgt studio

Rate this:
4.67 (6 votes)
Please Sign up or sign in to vote.
4.67 (6 votes)
20 Jul 2007LGPL3
An addin to Sql Server Management studio that lets you configure keybindings

Screenshot - Screenshot.jpg


This project is an addin to SQL Server Management Studio 2005 (tested in version 9.00.3042.00 of SSMS; that's SQL 2k5 with SP1 on Vista) for managing keybindings to built in commands (like Copy and Paste), and for other addins that might be registered.


I was writing some other addin, when in some weird way (must be my friend who did this) the Quick Search menu item lost its keybinding. I then wrote a very simple addin that fixed just that command, and then I thought I could improve on this addin to make a keybinding interface similar to Visual Studio 2005.

Using the code

I won't go into the details of creating an addin because there are so many others on that already does it. I will focus on the Command object instead.

What might be interesting is how to retrieve all the existing commands in SSMS, for example <b>Edit.Copy</b> etc. Command objects can be found in the Commands collection of the DTE2 object. To list all commands use:

foreach (Command command in _applicationObject.Commands) {

To retrieve a special command object use:

Command command = _applicationObject.Commands.Item("Edit.Copy", -1);

When you have a reference to the command object, the keybindings are in the Bindings property. It's an object array with strings on the format of "scopename::modifiers+key".

Scopename can, for example, be Global, SQL Query Editor & View Designer. Modifiers can be Ctrl, Shift & Alt. In the screenshot above you can see that Edit.Copy is bound to Global::Ctrl+C, but it is also bound to Global::Ctrl+Ins which means that you can have several bindings for the same command for different scopes.

These keybindings are stored in a .vsk file in your Document and Settings directory (mine is found in C:\Users\johan.sassner\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\Current.vsk).


To use the addin you have to register it using RegAsm (found in your v2.0 framework directory), and then run the included registry file. It adds the following key to the registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\Shell\
"FriendlyName"="SSMS Keybindings addin,SQL Server Management Studio Extension"

Points of Interest

I did stumble upon a weird bug, which, after a long time, I found a similar reference to a bug in Visual Studio 2003. If you remove the last keybinding on a command, it is not stored in the SSMS settings file. What I had to do was to find another command and just set that command binding object again (no changes, just re-set it).

private void PersistRandomCommand() {
  foreach (Command command in _applicationObject.Commands) {
    if (command.Name.Length > 0) {
      object[] bindings = (object[])command.Bindings;
        if (bindings.Length > 0) {
          command.Bindings = bindings;


v1.0 - 2007-07-11, added first version.

v1.01 - 2007-07-11, added how to install the addin.


This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


About the Author

Johan Sassner
Web Developer
Sweden Sweden
Working as a developer in the financial business. Been working with computers for 10 years, but have had computers as a hobby for 25 years.

Comments and Discussions

QuestionNot Working on Custom Addin Pin
mazzanti27-Jul-11 5:28
Membermazzanti27-Jul-11 5:28 
QuestionAny changes required to get this to work with SSMS 2008? Pin
kellyAtWork30-Dec-08 11:57
MemberkellyAtWork30-Dec-08 11:57 
AnswerRe: Any changes required to get this to work with SSMS 2008? Pin
Andrei b>g21-Mar-12 13:33
MemberAndrei b>g21-Mar-12 13:33 
QuestionHow to install the add-in and make it work? Pin
guaike22-Jun-08 14:43
Memberguaike22-Jun-08 14:43 
AnswerRe: How to install the add-in and make it work? Pin
Johan Sassner22-Jun-08 21:27
MemberJohan Sassner22-Jun-08 21:27 
AnswerRe: How to install the add-in and make it work? Pin
White X Dragon12-Oct-08 0:10
MemberWhite X Dragon12-Oct-08 0:10 
GeneralGreat! one question Pin
Win32nipuh7-Feb-08 19:43
professionalWin32nipuh7-Feb-08 19:43 
GeneralRe: Great! one question Pin
Johan Sassner10-Feb-08 2:33
MemberJohan Sassner10-Feb-08 2:33 
GeneralThanks for add-in! Pin
lepipele27-Nov-07 22:52
Memberlepipele27-Nov-07 22:52 
GeneralRe: Thanks for add-in! Pin
Johan Sassner27-Nov-07 23:40
MemberJohan Sassner27-Nov-07 23:40 
GeneralThanks! Pin
ChristianMerat18-Jul-07 5:52
MemberChristianMerat18-Jul-07 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 11 Jul 2007


26 bookmarked