My Favorite Visual Studio Shortcuts and Snippets

Keyboard Shortcuts

I've been speaking at user groups and conferences for a long time now. Usually at these short talks I don't get asked much about how I use Visual Studio.  But now that I am teaching Silverlight, my students are never shy about asking what I am doing while in Visual Studio.  I am often amazed by how people use Visual Studio without learning some of my favorite hotkeys/snippets.  Here are some of mine:

Keyboard ShortCuts

  • Ctrl-Shift-B: Build Solution
  • Ctrl-. (period): Show "Add Using/Imports" dropdown for unknown types.
  • Ctrl-K, C: Comment Selection
  • Ctrl-K, U: Uncomment Selection
  • Ctrl-K, F: Format Section
  • Ctrl-K, D: Format Document
  • Ctrl-Space: Show Intellisense List
  • Ctrl-Shift-V: Paste Loop - Hit Multiple Times to paste through the list of recent 'copies'
  • Ctrl-F: Simple Find
  • Ctrl-Shift-F: Find in Files
  • Ctrl-H: Simple Replace
  • Ctrl-Shift-H: Replace in Files
  • Ctrl-N: New->Project Item
  • Ctrl-Shift-N; New Project
  • F9: Set Breakpoint
  • Ctrl-Shift-R: Start/End Temporary Macro Recording
  • Ctrl-Shift-P: Play Temporary Macro Recording
  • F12; Navigate to Type (or metadata for Type) under the cursor

Snippets

(To use these snippets, type the phrase and hit Tab twice)

  • prop: Create a simple property in a class
  • propg: Create a simple property with a public get and a private set
  • foreach: Create a foreach block
  • sldpc: Create a Silverlight Dependency Property*

* This snippet is from the Silverlight Contrib snippet collection.

What are yours?

Comments:

Gravatar

CTRL-c & CTRL-v got me to where I am today.
How do you hit ctrl shift without feeling like an animal?

Gravatar

Ctrl-Shift is easy since I played too much Unreal Tournament and I used them as the primary/secondary fire keys.

Gravatar

Another nice snippet: ctor. This creates a constructor.

Apart from that, I love snippets so much I tend to roll my own, or enhance the existing VS ones to suit our company's coding guidelines. For example, I have one which implements the INotifyPropertyChanged interface.

Gravatar

I'm a "keyboard junkey" :> I love my shortcuts!

What do you do when you get a new install of Visual Studio?
http://www.pchenry.com/Home/tabid/36/EntryID/75/Default.aspx

Save Development Time With These Visual Studio Keyboard Shortcuts
http://www.pchenry.com/Default.aspx?tabid=36&EntryID=17

Gravatar

I highly recommend Dr. WPF's snippet library. Makes writing Dependency Properties and Routed events a breeze, and a lot of them have cross use with Silverlight:

http://www.drwpf.com/blog/Home/tabid/36/EntryID/41/Default.aspx

Gravatar

Something a use a lot on code I inherit from others is: Open a .cs file, right click, then select "Organize Usings" > "Remove and Sort". I regret there aren't built-in shortcuts for them, but it is just a matter of customizing new ones for that matter.

Gravatar

Thanks for the post: I love shortcuts!

1) Shift-Alt-F10 will do the same as Ctrl-. This is also good for implementing Interface stubs.

2) Ctrl-E-C will comment out the highlighted lines.

3) Of course, F5 will run in Debug, Ctrl-F5 will run without Debug.

And if you have ReSharper, Alt-Enter will do everything ;-)

Gravatar

My favorite key.... Alt+1 (*My* Refactor Key) via Coderush Xpress :) http://snurl.com/mijbi

Gravatar

Ctrl-K, F: Forma-->t<-- Document

A formal document is something different ;-)

Cheerz

-= Maarten =-

Gravatar

Cool tips.

However, your format shortcuts are reversed. It should be:

Ctrl-K, F: Format Section
Ctrl-K, D: Format Document

Gravatar

Another shortcut I use a lot is incremental find.

Ctrl+I and then start typing your search text.

http://vkreynin.wordpress.com/2008/10/18/incremental-search-in-visual-studio/


 



 
Save Cancel