Tag Archives: Visual Studio

Visual Studio 2010 keyboard shortcuts

I am fond of keyboard shortcuts and wish I was a keyboard-shortcut-ninja and didn’t have to rely on the mouse all the time.

Using keyboard shortcuts boosts productivity and ergonomically a better choice, as the risk of getting a tennis elbow/mouse elbow diminish.

Source of keyboard shortcuts for Visual Studio 2010:

Visual Studio 2008 shortcuts features

Two years ago I wrote an article about the shortcut features in Visual Studio 2005. So I thought, why not write one for Visual Studio 2008.

I am a big fan of shortcuts – it increases productivity and ergonomically better than using the mouse all the time.

There is a large arsenal of shortcuts not only for Visual Studio, but also for the add-ins like ReSharper. Most developer forgets the basic ones in Windows besides the cut and paste shortcuts. But they do provide a huge productivity boost. Take a look at this list – how many of these shortcuts do you know and use?

.Net debugger visualizers

The .Net framework 2.0 gave some great tools for debugging – they are a great help when writing code.

Some of these features are the DebuggerDisplay and DebuggerStepThrough attributes. I seldom use any of them, as I prefer to just overriding the ToString method instead of using the DebuggerDisplay attribute. This makes it easy to instrument the code too, as I can reuse the ToString method implementation for tracing.

Another feature is the ability to develop custom debugger visualizers. They enable smart developers to build their own. I find some really useful, especially the WCF visualizer. But there a many – check out this list of custom .Net debugger visualizers.

These small enhancements make it so easy to get an overview of the current state, instead of inspecting properties.

Visual Studio 2005 shortcuts features

I tent to forget the Visual Studio 2005 shortcuts really fast when I haven’t done any real coding and just Word “coding” for a while. The shortcuts are really important as they enhance my coding experience and boost my productivity (which makes my manager happy; which increase my bonus; which makes me even happier – it’s a full circle :-) ).
There are a bunch of standard Windows keyboard shortcuts which I will not discuss. But do take a look, as I doubt that you know all of them. More or less all can be used in Visual Studio.
These are essential Visual Studio 2005 keyboard shortcuts for C#

Debugging
F5 Start debug.
Ctrl + F5 Start without debug.
Shift + F5 Stop debug.
F9 Toggle breakpoint.
F11 Step into method – Executes code one statement at a time, following execution into
method calls.
F10 Step over method – Executes the next line of code, but does not follow execution through
any method calls.
Shift + F11 Step out of method – Executes the remaining lines of a method in which the current
execution point is located.
IntelliSense
Ctrl + Space List possible methods, classes etc.
Ctrl + Shift + Space Displays the name, number, and type of parameters required for the specified method.
Ctrl + J List members of a method.
Ctrl + K, I Displays the complete declaration for the specified identifier in your code in a Quick
Info tool tip. This includes exceptions!
Refactoring
Ctrl + R, R Rename dialog box, which allows renaming all references for an identifier.
Ctrl + R, O Displays the Reorder Parameters dialog box, which allows changes to the order of the
parameters for methods, indexers, and delegates.
Ctrl + R, V Displays the dialog box, which allows removal of parameters from methods, indexers,
or delegates by changing the declaration at any locations where the member is called.
Editing
Ctrl + M, O Collapses existing regions to provide a high-level view of the types and members in
the source file.
Ctrl + M, L Toggles all previously collapsed outlining regions between collapsed and expanded
states.
Ctrl + M, M Toggles the currently selected collapsed region between the collapsed and expanded
state.
Ctrl + K, C Inserts comments marking at the beginning of the current line or every line of the
current selection. This also works in HTML and XML files.
Ctrl + K, U Removes the comments marking at the beginning of the current line or every line of
the current selection. This also works in HTML and XML files.
Ctrl + K, D Formats the current document according to the indentation and code formatting settings
specified. This also works in HTML and XML files.
Ctrl + K, X Displays the Code Snippet Picker. The selected code snippet will be inserted at the
cursor position.
Ctrl + K, S Displays the Code Snippet Picker. The selected code snippet will be wrapped around
the selected text.
Ctrl + Shift + V Pastes text from the Clipboard ring to the cursor location in the file. Subsequent
use of the shortcut key iterates through the items in the Clipboard ring.

There are loads of other Visual Studio 2005 keyboard shortcuts for C# – you should check out this Microsoft poster or this complete list.
You can setup your own keyboard shortcuts under Tools | Options | Keyboard. The interface for setting up keyboard shortcuts sucks, but it is doable.

Keyboard shortcuts are not the only means of improving your productivity. Visual Studio snippets are a timesaver. They work by entering a snippet shortcut key and the pressing tab twice. Like “class + tab + tab”, then a class stub is created for you.

class Class stub
cw Console.WriteLne
enum Enum stub
exception Exception class stub
prop Property stub with getter and setter
propg Property stub with getter only
#region Code region stub
try Try/Catch block
tryf Try/Finally block

The snippet I love the most is exception – this snippet generates complete exception class in accordance with Microsoft guidelines. I used to hate implementing custom exceptions because it was so cumbersome.

You can see all the default snippets under Tools | Code Snippets Manager or keyboard shortcut Ctrl K, B ;-). You can also implement your own or do as I do; Google it.

You shouldn’t memorize all shortcuts, but adopt those which make your everyday life easier. You should however, every ones in a while think of expanding your arsenal of shortcut.

Have I missed any really important keyboard shortcuts or snippets? What are your favorite keyboard shortcuts and snippets? Let me know – I am expanding my arsenal :-D