8 Microsoft Visual Studio Keyboard Shortcuts You Need to Know Today

    Here are eight of my favorite keyboard shortcuts in Visual Studio. There’s a good chance at least one of them will be new to you.

    1. Move Code Alt+Up/Down

    This keyboard shortcut is new in Visual Studio 2013. If you put the cursor on a line of code and use the Alt+Up Arrow keys, the line of code you’ve selected moves up. If you use the Alt+Down Arrow keys, the line of code selected moves down.

    2. Create Collapsible Region Ctrl+M+H/Ctrl+M+U

    Chances are you’ve noticed the “+” and “-” symbols in the margins that let you collapse and expand your classes and functions. Did you know you can create your own collapsible regions? If you select a section of code and then use the key sequence Ctrl+M+H, you turn that region into a collapsible/expandable region. The key sequence Ctrl+M+U will remove the collapsible region. It doesn’t delete the code, it just removes the icon that lets you expand and collapse.

    3. Comment Code Block Ctrl+K+C/Ctrl+K+U

    Whether it’s because you’re trying to track down a “but,” or experimenting with code change, from time to time you’ll want to comment and uncomment blocks of code. If you select a block of code and use the key sequence Ctrl+K+C, you’ll comment out the section of code. Ctrl+K+U will uncomment the code.

    4. Peek Definition Alt+F12

    When you’re going through your code and you want to examine the code in the method you’re calling, many programmers will use the F12 key or the pop-up menu option Go To Definition. Go To Definition will navigate to the called method; however, many times you don’t need to navigate to the code. Sometimes, you just want a quick look at the method. If you’ve installed Visual Studio 2013, there’s a new keyboard shortcut — Alt+F12 — that will give you a preview of the method being called inline. You can use the Esc key to close the preview.

      5. Navigate Forward/Backward Ctrl+–/Ctrl+Shift+–

      When you have multiple files open at the same time, you might want a way to quickly move back and forth between two or three different locations in your code. If you’ve moved from one location to another you can use the keyboard sequence <Ctrl>+– to move to the previous location and then you can return using Ctrl+Shift+–.

      6. Ctrl-Shift-S

      Saves all documents and projects. Very useful when you have many items open and are too lazy to go to the top left “File->Save All.”

      7. F7

      Switches from the design view to the code view in the editor.

      8. Shift-F7

      Switches from the code view to the design view in the editor.





        Recent Posts