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
    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.
  2. Find active document in Solution Explorer
    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
  3. Debugger.Break
    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:

    catch (Exception)
      // Please report to ... if your debugger breaks here

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

  4. Cut the line
    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.
  5. Move line up or down
    Hold down ALT while pressing up or down and you’ll move the current line up or down.
  6. Zoom
    Hold down CTRL while you’re using the wheel on your mouse and you can easily zoom in and out as needed.
  7. Auto format the document
    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.

  8. Select vertically and update all lines at once
    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?
    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.
  9. 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.
  10. View all open windows in a list
    Press CTRL + SHIFT + TAB to open this overview window. You can then move around using the TAB key or the arrows. Very convenient!

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