Search

Tuesday, March 04, 2008

Top 13 Visual Studio Keyboard Shortcuts

My friends in college always made fun of my keyboard obsession. At the time, I knew all the Windows 98 specific shortcut keys and often had no need for the mouse. Keyboard shortcuts still rule in my book. It is amazing that you can get around without using a mouse at all. Master the following Visual Studio shortcuts and your colleagues might stare at you with amazement.

  1. F5: Start your project in debug mode

    vsShortcutsNumber1
  2. F7 & Shift-F7: Show the code windows & Show the designer window

    vsShortcutsNumber2
  3. Alt-Enter: Show the properties panel for a selected object (this is general Windows shortcut that can be used on files and directories)

    vsShortcutsNumber3
  4. F6 / Shift-F6 / Ctrl-Shift-B: Build solution / Build project / Build solution

    vsShortcutsNumber4 
  5. Shift-Alt-C: Add a new class to your project

    vsShortcutsNumber12 
  6. Ctrl-K + Ctrl-C: Comment a selected block of code

    vsShortcutsNumber5
  7. Ctrl-K + Ctrl-U: Un-comment a selected block of code

    vsShortcutsNumber6
  8. Ctrl-M + Ctrl-O / Ctrl-M + Ctrl-P: Collapse all code to definitions / Expand all code (stop collapsing)

    vsShortcutsNumber7
  9. Ctrl-M + Ctrl+M: Expend or collapse a selected code fragment. The code collapsed depends on where the cursor is located

    vsShortcutsNumber8
  10. Ctrl-B + Ctrl-T: Toggle code bookmark

    vsShortcutsNumber9
  11. Ctrl-Alt-P: Attach the debugger to a process. This is insanely useful for debugging ASP.NET web sites without having to start the project in debug mode

    vsShortcutsNumber10
  12. Ctrl-Alt-L: Show the solution explorer

    vsShortcutsNumber11 
  13. Ctrl-Shift-A / Alt-Shift-A: Add a new item to your project / add an existing item to your project

    vsShortcutsNumber13

The above list is my top 13. Did I miss any essential ones? What are yours?

Bonus:

The following work in Visual Studio just like they do in most other Windows application.

Ctrl-N: Add a new file

Ctrl-S: Save file

Ctrl-Z / Ctrl-Y: Undo typing / Redo typing

Ctrl-F: Bring up the "Find" dialog

Ctrl-H: Bring up the "Replace" dialog

Ctrl-Tab: Scroll forward through open windows

Ctrl-Shift-Tab: Scroll backwards through open windows

9 comments:

  1. What is the keyboard shortcut for switching the properties browser between properties and events?

    Note that pressing F4 on my settings (C# defaults) opens the property explorer.

    ReplyDelete
  2. There isn't one that I know of. You could however record a macro and assign it your own shortcut.

    ReplyDelete
  3. I tried to create a macro but recording does not work. I've tried to figure out the command inside the language, which is VB, but have drawn a blank. Perhaps someone else will figure it out. In the meanwhile, I'll send a suggestion back to Microsoft.

    ReplyDelete
  4. Ctrl-Space: CompleteWord
    Ctrl-Shift-Space: ParameterInfo

    more details at http://campey.blogspot.com/2010/06/intellisense-re-show-info.html

    ReplyDelete
  5. hi
    i would be really happy to find a keyboard shortcut for horizontal scrooling that would work like ctrl+upArrow or ctrl+downArrow does for vertical scrolling

    lp
    jure

    ReplyDelete
  6. Cool shortcuts, very useful. Thanks a bunch!!! I found a few move shortcuts here: http://www.usingcomputers.co.uk/tutorials/useful-windows-shortcuts.php its worth taking a look at combined with this article. Thanks, keep up the good posts!

    Big Thanks :D :D

    ReplyDelete
  7. Hey Boyan!

    I googled "Visual Studio Keyboard Shortcuts" and landed here. I was like, "Hey, this is Boyan's blog! I remembmer the tech-cats domain from back in the SubSonic days."

    Small world I guess.

    ReplyDelete
  8. Adam! Small world indeed. Drop me an email, I don't think I have your IM anymore.

    ReplyDelete

// //]]>