Visual Studio Tips

Visual Studio Keyboard Shortcuts

There are several pre-defined shortcut in visual studio and also You can change the keyboard shortcuts for most commands the changes will automatically saved in active-setting file and also you can export it and use in any other visual studio, you can generate the list of shortcuts and can take print of it.  





Determine the Shortcut Key Assigned to a Command


You can manually search the command whether or not it has an assigned shortcut key combination

To get the shortcut key combination for a command follow the steps give below

  1. Open Visual Studio
  2. On the Tools menu, click Options.
  3. Expand the Environment Link and select Keyboard. (If you do not see the Keyboard page, check Show all settings located in the lower left of the Options dialog box.)
  4. In the Show commands containing box, enter the name of the command without spaces(For example, solutionexplorer.)
  5. In the list, select the correct command.For example, View.SolutionExplorer.
  6. If a shortcut key combination exists for the command, the combination appears in the Shortcut(s) for selected command drop-down list.

Create Custom Shortcut Keys


Its a very helpful features of visual studio that you can create new shortcut key combinations for your own command or you can change the shortcut key combination for any other commands with existing combinations.

To create a new shortcut key combination
  1. Open Visual Studio
  2. On the Tools menu, click Options.
  3. Expand the Environment folder, and select Keyboard.
  4. In the Show commands containing box, enter the name of the command without spaces.For example, solutionexplorer.
  5. In the list, select the command you want to assign to a shortcut key combination.
  6. 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.
  7. 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.
  8. 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.
  9. Click Assign.

    Exporting and Importing of visual studio Shortcut Keys



    You can share the shortcut key combinations with you friends or you can use it to any other visual studio you can export it on to a file so others can import the data.

    To export shortcut keys only from visual studio
    1. Open Visual Studio
    2. On the Tools menu, choose Import and Export Settings Wizard.
    3. Select Export select environment settings and then click Next.
    4. Under What settings do you want to export?, clear all categories selected by default.
    5. Expand Options and then expand Environment.
    6. Select Keyboard and then click Next.
    7. For What do you want to name your settings file?, enter a name and then click Finish.
    To import only shortcut keys in visual studio
    1. Open visual studio
    2. On the Tools menu, click Import and Export Settings Wizard.
    3. Select Import select environment settings and then click Next.
    4. Click No, just import new settings, overwriting my current settings and then click Next.
    5. 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.
    6. Click Next.
    7. Under Which settings do you want to import?, clear all categories.
    8. Expand Options and then expand Environment.
    9. Select Keyboard and then click Finish.
    Some of the very useful keyboard shortcut used in visual studio are given below,

    • ctrl+k+c to comment a block of code.
    • ctrl+k+u to uncomment a block of code
    • ctrl+e+d  /   ctrl+e+c  /  ctrl+e+u   also works so you don't have to stretch your thumb aaaaaall the way to K ;)
    • Ctrl+Space will auto-complete the current word using IntelliSense. If multiple completions exist it will show a list of possible matches.
    • Ctrl+Shift+W will select the entire word in C# Express. (Ctrl+W only does this in Visual Studio Pro.)
    • Ctrl+X will cut the entire line that the cursor is currently placed on (without anything selected).
    • Ctrl+C will copy the entire line that the cursor is currently placed on (without anything selected).
    • Ctrl+L will delete *without copying* the line that the cursor is currently placed on. (Ctrl+X is easier)
    • Ctrl+T will swap two adjacent characters.
    • Ctrl+] will jump the cursor to the matching brace when the cursor is placed on a brace.
    • ctrl+M+O and ctrl+M+P, to open and close all regions of code.
    • ctrl+k+d to auto-format your code
    • ALT + ENTER: this little shortcut will open up the Properties window
    • CTRL + "k" + "s": This one opens up the code snippets dialogue within the code
    • F12: I think you all know this but still F12 is the shortcut for the "Go to definition" command which will take you to the definition of the object your marker is currently on.
    • F9: Another one i think you all know, clicking on F9 will add a breakpoint to the code line your marker is currently at. Clicking F9 again will remove this breakpoint from that line.
    • CTRL + ALT + "q": This one will open the Quick watch window while you debug
    • Incremental search:CTRL + I (and then type what you are looking for)
    • Search in every project file:CTRL + SHIFT + F
    • Save every modified file:CTRL + SHIFT + S
    • Show function signature:CTRL + SHIFT + SPACE (if cursor is after function call parenthesis)

    No comments: