Kirill's Visual Studio Tips

I decided to compile a small list of Visual Studio features that I use a lot.

Code Editor

  1. Code Snippets for ‘prop’, ‘foreach’, ‘if’, ‘class’, ‘interface’, Tab-Tab completion
  2. Surround with (snippets) - try, if
  3. Ctrl+K,D – FormatDocument
  4. Ctrl+Left/Right arrows in code editor – jump between words faster
  5. Ctrl+K,C – Ctrl+K,U – comment/uncomment selection
  6. Dynamic Snippets in the XML Editor - I bet a lot of people don't know about this one

Navigation

  1. F12 (Go To Definition) – position the caret on an identifier and hit F12
  2. Shift+F12 (Find All References) – then hit F8 to step through the results in the Find Symbol results window
  3. Click the “back” button on the Microsoft Explorer mouse with your thumb navigates back (under C# profile)
  4. Right-click on a document Tab – Copy Full Path, Open Containing Folder

Refactoring

  1. Position the caret on an identifier and hit F2 (Refactor -> Rename)
  2. Extract Method (Context Menu)

Code generation

  1. Generate Method Stub (Smart Tag) - Ctrl+. and enter
  2. WindowsContextMenuButton + O + ENTER + A – quick way to organize, remove and sort usings

Debugging

  1. Debug -> Exceptions (allows breaking on a first-chance exception)
  2. Right-click on a breakpoint brings up a context-menu which not everyone knows about ;-)
  3. Tools -> Options -> Debugging -> Enable just my code
  4. Attach to process -> Cross Platform Debugging (Managed, Native)
  5. .load sos, !clrstack, !dumpheap, !gcroot, etc.

Solution Explorer

  1. Tools -> Options -> Projects and Solutions -> Track Active Item in Solution Explorer
  2. Right-click on an item in Solution Explorer – Open Folder in Windows Explorer
  3. Right-click on a project -> Unload -> edit .csproj file in XML

Macros and automation:

  1. Coding productivity: macros, shortcuts and snippets
  2. How to map a Visual Studio macro to a keyboard shortcut?

P.S. Sara Ford has much much more in her famous Did you know series.

kick it on DotNetKicks.com