Visual Studio Tips & Tricks Listing

Thanks to Eric, Jared and Kirill for joining me today for the Live & On Demand Webcast. I'd like to provide a listing of the shortcuts and tips we talked about for your own reference. image

Code Editor

  1. Code Snippets for ‘prop’, ‘foreach’, ‘if’, ‘class’, ‘interface’, Tab-Tab completion
  2. Surround with (snippets) - try, if
  3. FormatDocument
    • C# Profile - Ctrl+K,D
  4. Ctrl+Left/Right arrows in code editor – jump between words faster
  5. Comment/uncomment selection
    • C# Profile - Ctrl+K,C – Ctrl+K,U
  6. Dynamic Snippets in the XML Editor

Navigation

  1. Go To Definition
    • C# Profile - F12
    • Metadata as source
  2. Code Definition Window
  3. Go To Definition Stack
    • C# Profile – Ctrl+Shift+F7, Ctrl+Shift+F8
  4. Find All References
    • C# Profile - Shift+F12, then hit F8 to step through the results in the Find Symbol results window
  5. Click the “back” button on the Microsoft Explorer mouse with your thumb navigates back (under C# profile)
  6. Document Tab
    • Copy Full Path
    • Open Containing Folder
  7. Iterating List Windows (Error List, Find Results, etc)
    • F8 next Item
  8. Open Document List
    • C# Profile – Ctrl + Alt + Down
  9. TODO Task List Items
    • Now Solution Wide in 2008 SP1
  10. Intellisense/Quick Info Transparency
    • Ctrl

Refactoring

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

Code generation

  1. Generate Method Stub (Smart Tag)
    • Ctrl+. and enter  (C# Profile)
  2. Remove and Sort Usings
    • Context Menu

Debugging

  1. First Change Exceptions
    • Debug -> Exceptions (allows breaking on a first-chance exception)
  2. Break Point Context Menu
    • Right-click on a breakpoint brings up a context-menu which not everyone knows about ;-)
  3. Source File and PDB Differences
    • Files don’t need to match
  4. Just My Code
    • Tools -> Options -> Debugging -> Enable just my code
  5. Managed and Native Debugging
    • Attach to process -> Cross Platform Debugging (Managed, Native)
    • Project properties
  6. Remote Debugging
  7. .load sos, !clrstack, !dumpheap, !gcroot, etc.

Solution Explorer

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