Visual Studio 2012: Tips and Tricks
I will explain some of features I usually use while developing and they increase my code productivity. Some of the explained tips in this post may be available in previous versions of Visual Studio.
This feature is available for C# and VB.NET. It allows you to pin the tabs to the left of the others tabs and in case you open many documents the pinned files will always be visible. To pin a document, click on on the pin icon as shown on the following figure
Ctrl + Shift + Tab
When you have many documents opened, one easy way to navigate through the opened documents is to click on the Ctrl + Shift + Tab and then click on the Tab key again to navigate through the opened document
To Navigate through the Active Tool Windows, all you need to do is clicking on the left arrow key.
This is a new feature in Visual Studio 2012. It allows you to search all tools and options available in Visual Studio. The Quick Launch box is available at the topic right corner of Visual Studio 2012 next to the minimize button.
Lets say I want to show the line numbers in the editor. Instead of trying to find that option in the Options dialog, I can just type “line number” in the Quick Launch textbox and that should take me there.
One of new features in Visual Studio 2012 is the ability to open files with out cluttering the tabs bar. The preview tab opens on the right side of the tabs bar.
To preview a file, you need to single click on the document. One of the limitations I found is that documents don’t open in design mode in the preview tab.
To activate the File Preview feature, you can either click on the Preview Selected Items on solution explorer
or type Preview in the Quick Launch textbox
Then check Allow new files to open in the preview tab and Solution Explorer
Navigate Backward and Forward
This feature is one of the most features I use on daily basis. The navigate backward allows you to move back and view the line of code you were working on before the current line. For example, if you were working on method X and then you moved to method Y, the navigate backward brings method X back on focus. The navigate forward moves the focus back to method Y.
To navigate backward, you press the Ctrl + – keys
To navigate forward, you press the Ctrl + Shift + – keys
This is an easy one, when you right click on the text editor, you get the Organize Using context menu item which has three options in its sub menu
Remove Unused Usings: deletes the using statements that are not needed (used).
Sort Usings: sorts the using statements alphabetically.
Remove and Sort: combines the above to commands.
One of the great productivity features in Visual Studio is code generation. For example, when you implement an interface or you type a class type that is either not implemented or you didn’t add the using statement for the the class’ namespace, you will see a blue underscore below the first letter
At that point, you can either click on the blue underscore or press Ctrl + . to see your options
Navigate To Dialog
The dialog can be launched by pressing on Ctrl + , . Its functionality is similar to the Search Solution Explorer in Visual Studio 2012.
Alt + Select
Alt + Select Allows you to select text vertically. For example, I have three methods that are marked as public and I want to change their visibility to private
I select the methods’ modifier, place the mouse cursor before the first public key word and then press the alt + select keyboard keys and drag with the mouse to cover the letter c of the third public keyword. After you had all the public keywords highlighted, you can type the keyword private
You will notice that the three modifiers are being changed at the same time.
Go To Line
If you know the line number in you code where you want to navigate to, press Ctrl + G to go to that line