Wednesday, February 8, 2017

Fixing Hot-Key issue in SSMS in five steps.

A lot of people in the Internet complain about their version of SSMS "forgot" some hot-key combinations. The oldest complain I remember was about the most useful combination "Ctrl-R".

The reason why SSMS "forgets" is within code sharing and reusability with other Microsoft development products.
If you have that problem, most probably I have (or had in the past) installed something else from Microsoft, such as Development Studio, Data Tools etc.

Won't concentrate on that, just provide the solution:

At first, got to the "Options":
- Menu -> Tools -> Options

- Or just simply press Alt+T -> O

Then Open "Environment" -> "Keyboard" -> "Keyboard".

Click to the text box on lower right called: "Press shortcut keys" and press "Ctrl+R"

In the correct environment you should see something like this:
In the drop down box "Shortcut currently used by:" you should see an option "Windows.ShowResultsPane (Ctrl + R (SQL Query Editor))"

If you do not have it - that is your problem.

For the sake of a Demo, I'll remove it in my SSMS and will fix it step-by-step.

Here is the Fix:

Step 1.

Go to Menu -> Tools -> Options -> Environment -> Keyboard -> Keyboard

Step 2.

In the Left-Middle ListBox search for a value "Windows.ShowResultsPane" and select it.
You should get something like this:

Step 3.

In drop down box "Use new shortcut in:" select "SQL Query Editor" and in "Press shortcut keys" text box press "Ctrl+R" to get something like this:

Step 4.

Press "Assign" button.
By doing this you assign key combination "Ctrl+R" to "Windows.ShowResultsPane" event within "SQL Query Editor" environment.
As the result, you have to get a new line in "Shortcuts for selected Command:" drop down box: "Ctrl+R (SQL Query Editor)".

Step 5.

Press OK and test how "Ctrl+R" works.


It looks easy, isn't it? The complication is only in the fact that Configuration options in SQL Server Management Studio show and allow to change shortcut keys not only for SSMS, but for other applications too.

If you have a problem with other unassigned hot keys the biggest problem is to identify "command" to assign for the key you need.

Here is a small list of commands for the most useful keys:
Shortcut KeyCommand
Ctrl + TQuery.ResultstoText
Ctrl + DQuery.ResultstoGrid
Ctrl + Shift + FQuery.ResultstoFile
Ctrl + NFile.NewQuery
Ctrl + SFile.SaveSelectedItems
Ctrl + OFile.OpenFile
Ctrl + FEdit.Find
Ctrl + HEdit.Replace
Ctrl + ZEdit.Undo
Ctrl + YEdit.Redo
Ctrl + AEdit.SelectAll
Ctrl + CEdit.Copy
Ctrl + VEdit.Paste
Ctrl + XEdit.Cut
Ctrl + Shift + UEdit.MakeUppercase
Ctrl + Shift + LEdit.MakeLowercase
Ctrl + K, Ctrl + CEdit.CommentSelection
Ctrl + K, Ctrl + UEdit.UncommentSelection
Ctrl + LQuery.DisplayEstimatedExecutionPlan
Ctrl + MQuery.IncludeActualExecutionPlan
Ctrl + JEdit.ListMembers