Visual Studio Productivity Tips

In this blog, I am going to share Visual Studio productivity tips. I will share some tips to generate code with shortcuts and some tips which are helpful to write quick code.


Please check the previous blog about Visual Studio keyboard shortcuts here in which I have shared Visual Studio keyboard shortcuts to improve productivity. 
The Visual Studio editor provides many shortcuts to generate code automatically and quickly. In fact, by pressing just 2-3 keys, it can write a whole syntax.

Quick Action

Quick action is a very helpful feature provided by Visual Studio. Visual Studio automatically shows the bulb icon wherever quick action can be performed. Shortcut keys for quick action are Ctrl+”+”. It will automatically detect the action which can be performed on the selected code; for example - if the cursor is at "using" namespaces, then it will show a tip to remove the unnecessary namespace. If the interface reference is added to the class, it will display the implemented interface and when we click, it will add all the methods of the interface into the class.

Visual Studio Productivity Tips

Code snippet

Code snippet is a great feature and my favorite one. Shortcut to insert snippet is Ctrl+K+X. Code snippet helps us to insert an already defined code template. Press Ctrl+K+X and a small tooltip window will populate with different options. Then, select one of them and select the code. You can also define your own code template for the snippet.

Visual Studio Productivity Tips

Add snippet

To add your own snippet, go to the location where visual studio is installed, in my case C:\Program Files (x86)\Microsoft Visual Studio 14.0, then enter into the language folder for which you want to add snippet e.g. VC#, then select snippet folder and reach the path C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC#\Snippets\1033\Visual C#, there will be many .snippet file, add new file with .snippet extension and set short name and code. Find complete details about snippet template see here.
Visual Studio Productivity Tips
In the above image I have added my snippet template which adds a method syntax when I type met tab tab.

Surround with

Surround with is another great shortcut feature provided by Visual Studio, if there is some code already written and then later that code needs to come inside “if” condition or “try-catch” block or be surrounded by “region” then instead of typing before the first line of code then add a bracket. Then after the last line close the bracket, just select the code which needs to be surrounded, then right click and select surround with or use shortcut key Ctrl+K+S. A small tooltip type window will open with many options which can be selected,  like if, region, try, try, for etc. Then select one of them and hit Enter. Now, the code is surrounded.  

Visual Studio Productivity Tips

Other Tips

The short typing approach is another feature which can help to speed up code writing, for example type ctrl + tab tab to write constructor syntax. It's very useful to add new property, method, constructor, class, if else, try catch. Just type 2-3 characters and it will generate the whole syntax.

There are many plugins available for Visual Studio like multi typing, resharper, and many others which provide various features to add more productivity.