Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Visual-Studio

10 ways to get more productive in Visual Studio

4.83/5 (22 votes)
20 Nov 2013CPOL3 min read 39.3K  
10 ways to get more productive in Visual Studio.

Visual Studio is full of shortcuts and handy tools helping you, as a programmer, to be more efficient in your work. Today I'm sharing a few of my favourite ones. All examples given here are tested in Visual Studio 2012.

  1. Open search result in a list
  2. Press CTRL + F to open the search pane. Enter your search string and then next to the find button you can open alternative search ways and select Find all.

    Find all

    Besides taking you to the first occurrence of the text searched for, Visual Studio also opens a Find Results window (normally at the bottom) with all the occurrences of the search phrase.

    Find results

    In this window you can click through all locations and at the bottom you'll also get some statistics of what has been found.

    Another way of doing this search is to press CTRL + SHIFT + F and click on the Find All button in the dialog that opens.

  3. Find active document in Solution Explorer
  4. Using menu options like “Go to definition” is great. But sometimes you’re taken to a document and you have no idea where the document belongs, especially if you have plenty of projects. By clicking on the Sync with Active Document button (see picture below), Solution Explorer will navigate to the location where the current document exists and mark it.

    Synchronize file views in Visual Studio

  5. Debugger.Break
  6. It might sound a bit strange to have a hard coded break in your code but it can be useful for testing purposes. Breakpoints are very handy but they can be easily turned off, while this line of code has to be removed to prevent debugger from stopping. An example is shown here:

    C#
    try
    {
    
    }
    catch (Exception)
    {
      // Please report to ... if your debugger breaks here
      Debugger.Break();
    }

    The Debugger class can be found in the System.Diagnostics namespace.

  7. Cut the line
  8. If you mark a text and press CTRL + X that text will be cut. But if you don’t mark any text and press the same CTRL + X the whole line (including carriage return) will be cut. You can also press CTRL + L to cut the whole line without the carriage return.

  9. Move line up or down
  10. Hold down ALT while pressing up or down and you’ll move the current line up or down.

  11. Zoom
  12. Hold down CTRL while you’re using the wheel on your mouse and you can easily zoom in and out as needed.

  13. Auto format the document
  14. Are you facing a document with a lot of wrong indentations? Press CTRL + K, CTRL + D to format the whole document. If you only want to format a smaller selection then select the code and press CTRL + K, CTRL + F. If you open the menu Tools | Options | Text Editor you can adjust how Visual Studio is going to do this formatting.

  15. Select vertically and update all lines at once
  16. Hold down ALT while you’re selecting a code snippet. You’ll then be able to do a vertical selection instead of line by line selection. Funky, right?

    VerticalEditSelect

    But it doesn’t stop there. You can also do a simultaneous update of all the lines you’ve marked. In the example below we’re able to change all variables at once from private to public.

    VerticalEditNew

  17. Scroll with arrow keys without moving marker
    Hold down CTRL while pressing up or down and you’ll scroll the window while keeping the marker at the same position. The effect is equal to using the scroll wheel on the mouse or the scroll bar at the side of the window, but you need the mouse to do both of them while this is a key-only option.
  18. View all open windows in a list
    Press CTRL + TAB or CTRL + SHIFT + TAB to open this overview window. You can then move around using the TAB key or the arrows. Very convenient!
    ctrlshifttab

More tips and tricks for Visual Studio can be found at these places:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)