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.
- Open search result in a list
PressCTRL+Fto open the search pane. Enter your search string and then next to the find button you can open alternative search ways and selectFind 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.
In this window you can click through all locations and at the bottom you’ll also get some statistics of what has been found. - 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 theSync with Active Documentbutton (see picture below), Solution Explorer will navigate to the location where the current document exists and mark it. - 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:TheDebuggerclass can be found in theSystem.Diagnosticsnamespace.
Cut the line
If you mark a text and pressCTRL+Xthat text will be cut. But if you don’t mark any text and press the sameCTRL+Xthe whole line (including carriage return) will be cut. You can also pressCTRL+Lto cut the whole line without the carriage return.- Move line up or down
Hold downALTwhile pressingupordownand you’ll move the current line up or down. - Zoom
Hold downCTRLwhile you’re using the wheel on your mouse and you can easily zoom in and out as needed. - Auto format the document
Are you facing a document with a lot of wrong indentations? PressCTRL+K,CTRL+Dto format the whole document. If you only want to format a smaller selection then select the code and pressCTRL+K,CTRL+F.If you open the menuTools|Options|Text Editoryou can adjust how Visual Studio is going to do this formatting. - Select vertically and update all lines at once
Hold downALTwhile 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. - Scroll with arrow keys without moving marker
Hold downCTRLwhile pressingupordownand 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. - View all open windows in a list
PressCTRL+SHIFT+TABto open this overview window. You can then move around using theTABkey or the arrows. Very convenient!