Seven essential Visual Studio 2010 keyboard shortcuts

Microsoft recently released some reference posters for the default keybindings in Visual Studio 2010 in pdf format. I’m constantly amazed by how few of these most developers seem to know so I thought I’d list my favourites. I use C# but the majority should work in VB and all but Ctrl + Comma will work in VS 2008.

Ctrl + Full Stop (.)

Displays the available options on the Smart Tag menu. This is by far my favourite, Smart Tags allow you to rename properties/methods/classes throughout your solution, add a required using statement or even create a new class/property/method.

Ctrl + Comma

Displays the NavigateTo window, which gives you search-as-you-type support for files, types and members. Scott Gu has a great blog post on just how useful this is.

F12/Shift F12

F12 will go to the definition of the currently selected symbol. Shift F12 will find all references for the currently selected symbol.

Ctrl + K, C/Ctrl + K, U

Ctrl + K, C comments out all currently selected lines of text or the current line if no text is selected. Ctrl + K, U uncomments all currently selected lines of text or the current line if no text is selected. This works in .js, .cs, .aspx, .config and .xml files.

Ctrl + K, D

Formats the current document according to the indentation and code formatting settings specified on the Formatting pane under Tools | Options | Text Editor | C#. Instantly tidy up a poorly formatted code file!

Ctrl + M, O

Collapses all declarations down to an outline to give you a quick high-level overview of your code file.

Ctrl + M, M

Toggles the currently selected region, method, class or property between collapsed and expanded view.