Thursday, May 15, 2008

Keyboard Shortcuts (Visual Studio) (Tip)

Visual Studio Keyboard Shortcuts

  • Control + '.'It is a shortcut for Control + Shift + F10 that opens the smart tage window and lets you add Using statement.
  • Control + Alt + 'Q' or Shift + F9: It will open the Quick watch window while you are debuging.
  • Control + Alt + Down: Shows dropdown of currently open files. Type the first few letters of the file you want to select.
  • Control + Alt + 'L': Shows Solution Explorer.
  • Control + '\' + 'E': Shows error list.
  • Control + Alt + 'O': Shows output pane.
  • Alt + ENTER: It will open up the Properties window.
  • Control + 'K' + 'S': It opens up the code snippets dialogue within the code. You can try this shortcut with some code selected and it will surround the selected code, with the chosen code snippet. Look at my other post for usage of code snippet.
  • Control + 'K' + 'C' and Control + 'K' + 'U': They are for commenting selected text (the 'c' options) and uncommenting selected text (the 'u' option).
  • Control + 'K' + 'F' and CRTL + 'K' + 'D': They will format the code in the window to be nicely indented. using 'd' will format all the document while using 'f' will format only selected text. The formatting is for all types of documents, HTML, Xaml, XML, C#… This one is my favorite.
  • Control + 'M' + 'O': Collapse to Definitions.
  • F4: Shows propoerites of the selected item.
  • F7: Toggle between Designer and Source views.
  • F9: It will add a breakpoint to the code line your marker is currently at. Clicking F9 again will remove this breakpoint from that line.
  • F10: Debug - step over.
  • Control + F10: Debug - Run to cursor.
  • F11: Debug - step into.
  • Shift + F11: Debug - step out.
  • F12: This one if for the “Go to definition” command which will take you to the definition of the object your marker is currently on.
  • Shift + F12: Find all references of a function or variable.
  • Shift + Del: It will cut the entire row from the document and past it to the clipboard. No need to select the row, just put the marker there and click Shift + Del and it is gone.
  • Control + C: Yeah, this is the standard shortcut of Windows. But, with Visual Studio, it will copy the line without even selecting it!
  • Control + Alt + 'E': It will open the Exceptions window, which allows you to tell Visual Studio to halt at specific exceptions, halt on all exceptions or selecet some exceptions to ignore.

Please post more, I will try and keep the list updated. Thanks.

Organize "using" statements (Visual Studio) (Tip)


This is very helpful feature of Visual studio 2008. Normaly, we tend to forget to remove unused "using" statements or if there too many, it's difficult to find out which one to remove. So, we rather keep them untouched.
Now, Visual Stuiod 2008 helps you organizing those. Just right click on the code and select "Organize Usings" menu. It gives you these thress choices:
Remove Unused Usings
Sort Usings
Remove and Sort
Happy coding!

Usage of code snippets (Visual Studio) (Tip)

With Visual Studio 2008, you can write fastest code ever!To use the code snippets, type-in code snippets (e.g. "for") shortcut, hit Tab twice, viola! The code will be added automatically. Code snippets can be reviewed or added. Look at the video for the details. Try and watch video in the full screen if you can. Don't know how well, will it be watchable.

This is what I use in the demo below:

class -> Tab -> Tab
ctor -> Tab -> Tab
tryf -> Tab -> Tab
for -> Tab -> Tab
cw -> Tab -> Tab
exception -> Tab -> Tab