Home > View Post

My new favourite keyboard shortcut in Visual Studio

On the subject of favourites I thought I'd share this little nugget with you that I got from a customer recently.

CTRL+K, CTRL+D (press one combination immediately followed by the other)

Not the easiest shortcut to remember but worth the investment - it reformats your code according to your preferences.

I used to achieve this by deleting and re-inserting closing braces '}' which causes the same event. Now I can do it without leaping about my source file. And the *best* thing about this keyboard shortcut is that it works in most file types! Yes! Including .xaml and .aspx.


What's your favourite little-known tip for Visual Studio?

Josh Post By Josh Twist
11:11 AM
26 May 2009

» Next Post: ViewModels and CheckListBoxes
« Previous Post: My favourite underused keyword in C# is...

Comments are closed for this post.

Posted by Tomas Restrepo @ 26 May 2009 2:51 PM
Notice that you can also use Ctrl+K,Ctrl+F in many cases to format just the selected text.

Posted by FallenGameR @ 27 May 2009 1:00 AM
Ctrl+M, Ctrl+O - collapse all regions
Ctrl+. - open smart tag (for automatic namespace adding for example)
Ctrl+Up/Down - scroll code

Posted by R2D2 @ 12 Jun 2009 5:11 PM
My favourite shortcut is this...



Posted by jsimas @ 28 Jun 2009 12:43 PM
A new one for me was Ctrl+M, Ctrl+L which expands all the folded code in a file.

Funny that both this post and the c# readonly post talk about stuff that is very natural and prevalent if you use Resharper.

© 2005 - 2022 Josh Twist - All Rights Reserved.