Since we got so many comments with lots of useful information on our Visual Studio Shortcuts post we decided to use those comments and some other shortcuts we found and compile another list so lets get going

  1. CTRL + "K" + "M": This one is Genius.
    Incase you need to add a method to an
    already existing class you just write the method
    as if it exists :

       1: int i = 5;

       2: bool flag = NewMethod(i);


    Click on the shortcut and you will get the

    following method stub:

       1: private bool NewMethod(int i)

       2: {

       3:     throw new NotImplementedException();

       4: }

    Great isn’t it?

  2. CTRL + ".": This one expands the one before it, say you need to add a functionality to a different class. again all you have to do is use the method as if it exists:
       1: int i = 5;

       2: bool flag = DifferentClass.NewMethod(i);

    Put the cursor on the new method, click the shortcut and you will see this:

    Create Method Stub 
    Hit Enter and you will get a new method stub with the return value and the parameter, in the other class.

       1: public class c

       2: {

       3:     internal bool NewMethod(int i)

       4:     {

       5:         throw new NotImplementedException();

       6:     }

       7: }

    Definitely my favorite.

  3. CTRL + "-" and CTRL + SHIFT + "-":  These two are similar to the Forward and Backwards buttons of the WebBrowsers and will take you to all the places your curser was, Very useful for those times you click F12 to go to definitions and then have no clue where you were before :). (Thanks Vijay Santhanam).

  4. ALT + ENTER: We talked about it in the last post, but it seems that this shortcut will open the properties window on anything that moves, even Files in your Windows Explorer. (Thanks to Bryan Migliorisi from http://www.Migliorisi.com).

  5. SHIFT + ALT + ENTER: This one will switch you Visual Studio to Full Screen mode, which is very useful in those boring presentation when you have to show your code through a projector on a screen. Another click will get you back to normal mode. (Thanks to Pablo Marambio).Visual Studio Full Screen

  6. CTRL + "M" + "M": This one will collapse the region your cursor is at whether its a method, namespace or whatever for collapsing code blocks, regions and methods. The first will collapse only the block/method or region your cursor is at while the second will collapse the entire region you are at. (Thanks to knave).

  7. CTRL + ALT + "P": This will open up the attach to process window, very useful for debugging. (Thanks Greg Beech from http://gregbeech.com).Attach to Process

  8. CTRL + "R" + "R": This one is used to quickly rename a method/ variable or whatever. (Thanks again to Greg Beech).Rename Method

  9. F8 and SHIFT + F8: These two are great! they are similar to the shortcut number 3 but they will take you forward and backwards in your search results just search for something and then start hitting F8 and you will see. (Thanks to David Hu).

  10. CTRL + SHIFT + "B": This one will invoke build solution. ( Thanks to Matt Brunell).

  11. CTRL + "B" + "T": This one will allow you to quickly add or remove a bookmark from a line of code.

Truly some great and helpful shortcuts. Thanks to everyone who commented, and looking forward to hearing what else you have.

If you want some more cool options for your visual studio check out Power Commands. And once again if you think we missed anything, comment.

Enjoy.

Amit.

Tags :

51 Responses to “11 More Visual Studio Shortcuts You Should Know”


  1. speps

    Said on May 6, 2008 :

    So the first one also introduces typos?
    “private bool NewMethos(int i)”

    Just kidding, great shortcuts.

  2. chris

    Said on May 6, 2008 :

    I noticed that you try to hide the article when Adblock is enabled. I think that extremely annoying. The first few times I clicked on a link to your site, I thought “what a ****” there isn’t even an article, just a lot of bla bla. Looked like some kind of link farm without content…

    You should at least show are warning that users disable Adblock. Else they’ll just move on and never visit your site again. Ever.

  3. configurator

    Said on May 6, 2008 :

    Ctrl-”.”: I always use Alt-Shift -F10 in my work, which is the same.
    It also helps with renaming (in the definition of a method/variable/class/whatever, change the name and the little box will appear. Press ctrl-”.” or Alt-Shift-F10, and it will suggest the rename operation).
    And with completing namespaces (e.g. type
    namespace TheNamespace { class Thing { } }
    namespace OtherNamespace {
    class OtherThing {
    void doit() {
    Thing x = new Thing();
    }
    }
    }
    , put the cursor on one of the Things in the line Thing x = new Thing();, and it will suggest the completion)

    Ctrl-”B”-”T”: Also Ctrl-”K”-”K”.

    And I have a question about Ctrl-”-”: I use that a lot. But I also always accidentally pres the back button on my IBM Thinkpad keyboard (because it’s right next to the direction keys – very annoying).
    Visual studio then goes to some obscure file or another, but I never figured out how it decides where to go. Also, the same with the forward button.

  4. Kimmen

    Said on May 6, 2008 :

    Ctrl + M + O, similar to number 6 but does it to alla collapsable regions in the document.

    F2 does the same thing as Ctrl + R + R.

  5. Shahar Y

    Said on May 6, 2008 :

    Chris,

    Although we are not happy with you using adblock, we are not trying to hide anything when Adblock is enabeled. Moreover, we tested Dev102 with adblock and it works fine. There must be something else that causes you to not see our posts. Can you add more details?

  6. Hector

    Said on May 6, 2008 :

    Everytime I try to use the “Ctrl + K + M” shortcut Visual Studio says the command is not available at the moment. Why? I’ve tried selecting the whole function call, part of it, etc and no success.

    I’ve not been able to use the second one either.

  7. Mahesh Kumar R

    Said on May 6, 2008 :

    thanks amit.

    Regarding Tip # 11:
    For bookmark alternatively you can use,
    CTRL + “K” + “K” ( for add and Remove)

  8. Amit

    Said on May 6, 2008 :

    @ Mahesh

    are you certine that your cursor was on the method call?

  9. Scott

    Said on May 6, 2008 :

    Same problem as Mahesh. Neither 1 or 2 work for me. Generate Method Stub is disabled, even if I add a toolbar button for the same command.

  10. Brian Lowry

    Said on May 7, 2008 :

    I’m a big fan of CTRL + K + C and CTRL + K + U for commenting and uncommenting code… seems to work everywhere but CSS stylesheets.

  11. Sam

    Said on May 9, 2008 :

    Great article, some new ones there for me. On the subject of expanding regions, Ctrl + “M” + “L” will expand all collapsed sections in the current file.

    If the code file doesn’t contain any collapsed sections, each section will be collapsed. This isn’t so handy as it collapses all collapsable sections, not just regions.

  12. Brian Canzanella

    Said on May 21, 2008 :

    My favorite is Ctrl+Shift+F9 which will delete all breakpoints.

  13. Mark Sowul

    Said on May 21, 2008 :

    For CTRL-R, R – another alternative is the usual Windows rename shortcut, F2.

  14. Amit

    Said on May 21, 2008 :

    I did not know about the F2 option, Very nice! Thanks Mark

  15. AI

    Said on May 22, 2008 :

    To expand on shortcut #2 – using ‘Ctrl’ + ‘.’ after Type names (or anytime you see a tiny block under what you just typed) also provides a different context menu e.g. if you use it after the class name Path (from System.IO) it will display a context menu with the option to either include the System.IO namespace or use the fully qualified name i.e. System.IO.Path. Very useful when you are using classes that you haven’t referenced yet.

    Thanks for the shortcut list. Some of them that I didn’t know about are going to be real time savers especially Ctrl + Alt + P.

  16. Jan Wikholm

    Said on June 6, 2008 :

    Hello,

    Just a tip for #3 – if you have a mouse with the forward/back buttons (such as Logitech MX510) you can use those instead of the keybindings :)

  17. Mohan

    Said on June 12, 2008 :

    There is one great book available in infoQ Please read…..

    Visual Studio .NET Tips and Tricks explains how to use VS.NET efficiently. Organized into short and easy-to-grasp sections, and containing tips and tricks on everything from editing and compiling to debugging and navigating within the VS.NET IDE, this book is a must-read for all .NET developers, regardless of expertise and whether they program in C#, VB.NET, or any other .NET language. This book covers the Visual Studio .NET 2002, 2003, and 2005 Beta 1 releases.

    http://www.infoq.com/resource/minibooks/vsnettt/en/pdf/vsnettt_infoq.pdf

  18. sxd

    Said on June 23, 2008 :

    Hi,
    I’m having some kind of weird thing with my VS2008. It opens TWO instances fo IE when I hit CTRL+F5 in order to run an app. Never happened before. Now I can’t change it. Any idea?
    Thanks!

  19. Shahar Y

    Said on June 24, 2008 :

    Hi sxd,

    Try to see how the Ctrl+F5 is customized in your VS2008. Check this page http://msdn.microsoft.com/en-us/library/bb245788(VS.80).aspx and read the Customizing Keyboard Shortcuts section. Hope that will help…

  20. John

    Said on September 3, 2008 :

    Can anyone post the shortcut for generating the getters and setters for a property. thanks

  21. Shahar Y

    Said on September 3, 2008 :

    @ John

    Print “prop” and then hit TAB+TAB (hit twice on TAB) and you get it.
    It is important to mention that this is not a keyboard shortcut but a code snippet.

  22. SunKwon Kim

    Said on October 12, 2008 :

    These shortcuts are useful to me.
    Especially, No.2 and No.8 shortcuts are cool.
    http://www.wpfstory.com/entry/11-More-Visual-Studio-Shortcuts-and-one-additional-shortcut-you-shold-know

  23. piyush

    Said on February 24, 2009 :

    For Getter and setter method , i have one very great shortcut, first type PROP and then hit TAB button twice. :-), 100% working.

  24. Sangam Uprety

    Said on June 9, 2009 :

    Ctrl+Shift+H is equivalent to Ctrl+H and does very smart job for find and replace. Further, first do Ctrl+F for find and then just press F3 for next match. Easy!

    A number of such short keys have made life easier. These ones are also worth looking at: http://dotnetspidor.blogspot.com/2009/06/22-visual-studio-short-keys-and-6-short.html

    Happy Programming!

  25. Wayne Erfling

    Said on June 19, 2009 :

    Happy to find the Ctrl+M +M shortcut, but I’d also like to know what function it maps to, so I can change it.

    Maybe “knave” knows?

  26. mharpen

    Said on July 4, 2009 :

    I just installed vs2008 and am getting strange behavior when I press Ctrl+F5 in my web application solution. It opens IE and shows the start page fine, but when I close the IE page, another IE duplicate page opens up. Very frustrating. It doesn’t do this when I set Debug=True in the config and just press F5. Anyone have any idea what might be going on? I’m on Vista, and I haven’t changed any keyboard shortcuts. I even tried just creating a new web application with the default page, and pressed Ctrl+F5, and get the same behavior. Also, I find that if I wait about 45 seconds before closing the first IE page, and watch the VS2008 Output window, it will eventually say build complete. Then I can close the IE page and it will not reopen a second time. Again, this is even with just a new blank web application project. Thanks in advance. -Mark

  27. best used car dealerships in phoenix

    Said on March 24, 2014 :

    They are specifically designed intended for meeting small urgent income requirements of people.
    Obtaining a loan with a no credit auto loan dealer Phoenix can be beneficial for people with poor credit.
    USA harbors these institutions which would give preference
    to your overall body of work rather than the scores on standardized exams.

24 Trackback(s)

  1. May 6, 2008: Visual Studio Links #24 : Visual Studio Hacks
  2. May 6, 2008: 11 More Visual Studio Shortcuts You Should Know « Rams On It - .NET
  3. May 7, 2008: Dew Drop - May 7, 2008 | Alvin Ashcraft's Morning Dew
  4. May 10, 2008: Interesting Finds: 2008.05.10 - gOODiDEA.NET
  5. May 21, 2008: May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF - ScottGu's Blog
  6. May 21, 2008: BusinessRx Reading List : May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF
  7. May 21, 2008: May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF - Mirrored Blogs
  8. May 21, 2008: Great VS Shortcuts
  9. May 22, 2008: 5?20????? ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF - Joycode@Ab110.com
  10. May 23, 2008: Enlaces de Mayo: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF « Thinking in .NET
  11. May 24, 2008: May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF « .NET Framework tips
  12. May 25, 2008: Planeta C# » May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF
  13. May 26, 2008: Deniz Dülec » My favorite VS2005 Shortcuts and Tricks
  14. May 31, 2008: Silverlight Hub » May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF
  15. Jun 6, 2008: Visual Studio shortcuts - Gerlei Márton blogja az Architektúra Fórumon
  16. Jun 12, 2008: CREATING VS KEYBORAD SHORTCUTS CHEAT SHEET | Dev102.com
  17. Jun 15, 2008: May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF - Readed By Wroc?aw NUG members - Wroc.NET
  18. Aug 1, 2008: Liens du 20 mai: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF - Scott Guthrie's Blog in French
  19. May 8, 2009: Visual Studio shortcuts - Bilal Shouman
  20. Jan 10, 2010: Read This Link » 11 More Visual Studio Shortcuts You Should Know
  21. Apr 12, 2010: Useful Visual Studio Shortcuts - MVi
  22. Apr 12, 2010: Useful Visual Studio Shortcuts - MVi
  23. May 4, 2010: May 20th Links: ASP.NET, ASP.NET AJAX, .NET, Visual Studio, Silverlight, WPF | OOP – Object Oriented Programing
  24. Dec 19, 2011: More 11 Visual Studio Shortcuts You Should Know » ?????? ???????? ????? ??? ???

Post a Comment