2 out of 7 rated this helpful - Rate this topic

How to: Work with Keyboard Shortcuts

The shortcut key combinations in the scheme currently applied, (Default), depend on the settings you have selected as well as any customizations you might have made. For more information about the shortcut keys associated with a settings combination, see Working with Settings.

Visual Studio also includes seven other keyboard mapping schemes, each of which differs from the others in the shortcut key combinations assigned by default to various UI elements. For a list of these combinations, organized by mapping scheme, see Pre-defined Keyboard Shortcuts.

Commands with shortcut key combinations that are part of the Global scope can be superseded by commands in other scopes depending on the current context of the integrated development environment (IDE). For example, if you are editing a file, commands that are part of the Text Editor scope have precedence over commands in the Global scope that start with the same key combination. For example, if several Global commands have key combinations that start with CTRL + K and the Text Editor also has several commands with key combinations that start with CTRL + K, when you are editing code the Text Editor key combinations will work and the Global key combinations will be ignored.

NoteNote

The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help depending on your active settings or edition. This Help page was written with General Development Settings in mind. To change your settings, from the Tools menu, choose Import and Export Settings. For more information, see Working with Settings.

You can manually search for a command to determine whether or not it has an assigned shortcut key combination.

To determine the shortcut key combination for a command

  1. On the Tools menu, click Options.

  2. Expand the Environment folder and select Keyboard.

    Note Note

    If you do not see the Keyboard page, check Show all settings located in the lower left of the Options dialog box.

  3. In the Show commands containing box, enter the name of the command without spaces.

    For example, solutionexplorer.

  4. In the list, select the correct command.

    For example, View.SolutionExplorer.

  5. If a shortcut key combination exists for the command, the combination appears in the Shortcut(s) for selected command drop-down list.

You can create new shortcut key combinations for any command or change the shortcut key combination for commands with existing combinations.

To create a new shortcut key combination

  1. On the Tools menu, click Options.

  2. Expand the Environment folder, and select Keyboard.

    Note Note

    If you do not see the Keyboard page, check Show all settings located in the lower left corner of the Options dialog box.

  3. In the Show commands containing box, enter the name of the command without spaces.

    For example, solutionexplorer.

  4. In the list, select the command you want to assign to a shortcut key combination.

  5. On the Use new shortcut in drop-down list, select the feature area in which you want to use the shortcut. For example, you can choose Global if you want the shortcut to work in all contexts. Unless the same shortcut is mapped (as Global) in another editor, you can use it. Otherwise, the editor overrides the shortcut.

    Note Note

    The following keys cannot be assigned to a command in Global: PRINT SCRN/SYS RQ, SCROLL LOCK, PAUSE/BREAK, TAB, CAPS LOCK, INSERT, HOME, END, PAGE UP, PAGE DOWN, Windows logo keys, Application key, any of the ARROW keys, or ENTER; NUM LOCK, DEL, or CLEAR on the numeric keypad; or CTRL+ALT+DELETE.

  6. Place the cursor in the Press shortcut key(s) box, and then use the keyboard to enter the key combination you intend to use for the command.

    Note Note

    Shortcuts can contain the SHIFT, ALT, and/or CTRL keys in combination with letters.

    Be sure to check the Shortcut currently used by box to see if the key combination is already assigned to another command in the mapping scheme. Press BACKSPACE to delete the key combination, if the combination is already in use, before trying another combination.

  7. Click Assign.

    Note Note

    Changes made using the Assign button are not cancelled if you click the Cancel button.

You can share the shortcut key combinations in the current keyboard mapping scheme by exporting the information to a file so others can import the data.

To export shortcut keys only

  1. On the Tools menu, choose Import and Export Settings Wizard.

  2. Select Export select environment settings and then click Next.

  3. Under What settings do you want to export?, clear all categories selected by default.

  4. Expand Options and then expand Environment.

  5. Select Keyboard and then click Next.

  6. For What do you want to name your settings file?, enter a name and then click Finish.

To import only shortcut keys

  1. On the Tools menu, click Import and Export Settings Wizard.

  2. Select Import select environment settings and then click Next.

  3. Click No, just import new settings, overwriting my current settings and then click Next.

  4. Under My Settings, select the settings file that contains the shortcut keys you want to import, or click Browse to locate the correct settings file.

  5. Click Next.

  6. Under Which settings do you want to import?, clear all categories.

  7. Expand Options and then expand Environment.

  8. Select Keyboard and then click Finish.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Confusing and lacking in design
Let's say I right click on a ribbon button because I want to change the comment and uncomment from dumb-stupid ctrl-k ctrl-c and ctrl-k ctrl-u to just plain simple ctrl-[ and ctrl-]. See how it is soooooo much simpler to just have a single key? Do you guys even program? Or do you still have to be different from 1984 Mac conventions because you are _special_?$0$0 $0 $0Next up comes a dialog. Now is the dialog ready to edit that particular command? *** no. First I have to click keyboard button to get another dialog. I have to then scroll through a 3 high TINY little dialog in the middle of my gigantic 30" 2560 x 1600 monitor. Or I have to search for it if I happen to know the name of the command and then scroll through the results.$0 $0$0 $0 $0Ok so lets say I finally found this one magic command that is in fact the one I right clicked on to begin with. I assign a shortcut to it and its companion and then try it out. Shut the front door! Only the uncomment one works. Now when I assigned them it warned me that some useless rubbish was already bound there and I got rid of them by accepting. Epic fail though, it in no way indicated that there is some other command in some higher precedence layer that overrides my command. Why not say so right there?$0 $0$0 $0 $0Also please, for the love of god, go and slap right in the face, each of your devs with two giant monitors on their desk that nevertheless design dialogs that not only do not resize but open up in some goddamned micro size by default. In fact, just punch them. This ... is ... 2011. Get a clue please.$0


StevenPo (MSFT) replied - You can submit feature suggestions (or even just feedback about why a feature doesn't work for you) by using Microsoft Connect (http://connect.microsoft.com/visualstudio). If you post a link to your connect item in the MSDN forums, other users can vote on your suggestion.
Need More Documentation On The Context Drop Down Menu Choices
I like to add my own keyboard shortcuts or redefine existing ones to the operations that I perform most often. But with the expanding capabilities of Visual Studio 2010, this is getting much harder to do, and I think this page of documentation needs some additional information or a link to another page somewhere.

The problem I have is that I do not know how to determine which of the choices on the "Use new shortcut in:" drop down menu I should choose. In earlier versions of VS I normally just left that set at Global and it would work, but not so with VS 2010. I suspect that is because there are more context specific shortcuts defined in VS 2010 than in earlier editions.

So what I think I need to know is:

1. What context is is that I need to add the shortcut to. In my case, I write C# code, so what context do I change for that? I have tried assigning a shortcut to the Global context, and the Text Editor context, but then when I get back into my C# editing, the shortcut I just assigned does not work, which tells me that some other unknown keyboard context is in use.

2. I think it would be good to have documentation on what each of the context choices are on that drop down menu.

Other comments:

IMHO, most of the dialogs in Visual Studio have less than stellar user interface designs, as follows:

1. Almost none of them are re-sizable. This one is a great example of why it is a weak UI design... look at the list of possible commands... it is a list that has hundreds of entries, but you can only see 4 at a time on this dialog, and since you cannot re-size this dialog, you have no way of being able to see more of that list. (Personally, I think a TreeView control would be a good choice here)

2. The Assign key - this only allows you to assign one shortcut to one context menu at a time. I would prefer to have check boxes by each of the contexts and then be able to assign a new shortcut key to whatever contexts I have checked.