About:
The Visual studio editor is vast and provides a ton of features. As you are working with visual studio editor, you should know the few features for those helps you a lot to improve the productivity while developing a code.
So, In this post I am going to share with you about some of visual studio key points.
- Features
- Extensions
- Web Essentials
- code snippets
- Help
- Quick Launch
- Refactoring
If you follow the above set of key points in visual studio along with some other, then while writing a code in visual studio is just like a “Communication or discussion between you and visual studio”.
Features:
- Multiple Browsers set as Default
- Show code Preview tool tip
- Peek Definition
Multiple Browsers set as Default:
This feature is really very helpful when you get a chance to work on application, it should support various browsers.Normally, what you should do is run an application in one browser and then copy the same url to another browser to check the browser dependency or UI perspective or some other ways.
But, In Visual studio also provides an option to set “Multiple Browsers” set as default. So you can run the application from visual studio it would open in all browsers. So, The setting should be setup by the following way.
As, per the browser the default browser is “Google Chrome”. Click on Browse with button then the screen should display as below.
Now, Press the Ctrl button and click on “Firefox” then you are able to select two browser types (Just like select multiple list items from list box) and then hit on “Set as Default” button then the resultant screen would display is as follows.
Then close the window and hit a “ Ctrl + F5” button to run the application in two browsers (Google Chrome, Firefox) at a time.
Note: The debugging feature (hit F5) is allow only for single application only. This multiple browser feature would be useful especially to test the GUI display for various browsers.
Show Code preview tool tip:
This feature will be useful when code file contains hundreds of lines, In out of that you are going to search for particular block / piece of code.
So, Normally to achieve the aforesaid requirement, you can use find or method name search for that few key strokes are required,
Instead of that, while just moving the mouse to the vertical scroll bar location as it opens a small glance popup it would show the piece of code and just by clicking on that it would navigates to that particular code location is good right!!!..
Now, you can learn how can you setup this feature in visual studio 2013.
Steps:
- Tools
- Go to Options
- Expand Text Editor
- Expand C#
- Select Scroll Bars
- Go to the Behavior panel
- Select the “Use map mode for vertical scroll bar”
The resultant window screen looks like as follows.
Note: I hope this feature will be helpful when you are working on big screen like extended monitor it would be useful, for normal small laptop screens you can go with existing vertical bar only.
Peek Definition:
As a coding practice and better maintainability will follow code ayers or design patterns. In such a scenario, some of the methods will be inherited from the other classes.
So, In that cases if you want to check the method details with out moving to that particular this Peek definition helps you.
You, just need to place a cursor on any of the method and click on “Alt + F12” it opens small popup contains the method details.
Extensions:
Visual studio supports the extensions which helps to achieve the required things those are not included or in a better way by creating visual studio extensions in (.vsix) file format.
You can install/manage the visual studio extensions from Visual studio itself,By Navigating to Tools and Extensions and Updates.. or else you can directly install extensions from Visual Studio gallery. Some of the extensions are as follows.
- Spell checker
- Go To Definition
- Productivity Power Tools 2013
Spell checker:
Spell checker is one of the great tool as this would be very useful to get rid of some silly/typo mistakes while placing some comments in code level. As placing comments at code level is one of the best thing in code practices.
You can download the tool from this link
Spell Checker or else you can directly install from visual studio as well.
Go To Definition:
Visual studio provides so many features like (F12) to go to the definition of code and (Alt+ F12) peek definition to view the code in current location window only with small popup also. Even though this extension provides in a other way to view the code.
If you press and hold the Ctrl key and just mouse over any definition then it turns into a hyper link, By clicking on that link it would navigate to that definition of the code block.
You can download that one from this link
Go To Definition
Productivity Power Tools 2013:
The name itself indicates that this tool is very helpful to improve the productivity while writing the code in visual studio 2013. you can call this one as a package instead of extension as this comes with lot of options with customization settings even you can disable / change the setting as you desired.
you can check out description and get the details and download the extension from this link
Power Tools.
Installed Extensions in a visual studio having a features like to disable or uninstall the extensions as well.
The Extensions are managed from Visual studio by following this steps.
- Tools
- Go To Extensions and Updates
- select Installed option on left most corner from the opened pop up
- It would show the list of installed extensions
- Now, You can disable or Uninstall the required extension.
Web Essentials:
Web essentials is also one of the best one which will provide great flexibility while writing a code in visual studio editor.
LESS: Less css is kind of dynamic stylesheet language which is very helpful while designing css for any templates or forms. you can get more details from my
blog.
ZenCoding: ZenCoding is the one of the greatest feature (at least I feel) in the Web essentials. It helps you a lot to write HTML code in fastest way even visual studio 2013 provides itself a lot of features like (automatically closes (or modify/update) the tag when you write start tag and etc). You can get additional details from my
blog.
It also contains a great list of features like TypeScript and etc. you can get more idea about web essentials by checking this link
Web Essentials. you can download the web essentials separately based on visual studio version, For Visual studio 2013 the link for visual studio gallery and official site link
web essentials.
Code Snippets:
As a developer, Everyone have an idea of some basic C# code blocks like (if.. else, for, foreach, switch,while, creating constructor etc etc..)
But, Just think about it while choosing any one of the aforesaid code block, and just have a count of how many key strokes are used to write that block.
For Example, for writing single if condition like the below it would take minimum of 6 to 7 even visual studio provides automatic feature of closing of braces.
if()
{
}
But, If you have an idea of code snippets, you can achieve that one in only 4 key strokes. By typing
“if” and then press
“TAB” then visual studio will create if block for you.
The other example is, If you are having a class named as “Customer.cs” then you are going to create constructor for that class. By using code snippet you can just type
“ctor” and then
hit TAB.
Thats it!!!!... The constructor is ready with the code.
In the similar way for writing try..catch block, just write
“try” and then hit TAB.
In the above scenario,The difficult thing is only you just need to have an idea on “ctor” will creates code snippet for constructor block.
Now, The question is how should you know these kind of things.
It is just simple, In any of the code block (c#) or even in .cshtml page block as well, Right Click and then click on “Insert Snippet” then the resultant screen would display like the below.
you can select or review the code snippet names by checking in “Visual C#” or “ASP.NET MVC4” or others and then habituate in the day to day coding style then definitely you could do better code in a productive manner.
Help:
As a developer, you can learn the things in a day to day code by exploring the things. In this manner, Help is needed to learn or understand the things, The same scenario, you could relate with visual studio editor code implementation.
For Example, if you want to get the details about a C# keyword “string”. Instead of searching in google or somewhere else , place a cursor on that keyword and hit “F1”.
The specialty of this search is sensitive framework dependent. Like , If you hit “F1” from the .Net Framework 4.5 application then the msdn help browser will open the result for .Net Framewoek 4.5 only.
The Visual studio provides offline base search also by changing the help preferences from visual studio.
Quick Launch:
This option is exists generally at right most corner of visual studio. Before discussing with you about this feature, just a few simple questions.
- Have you ever searched in VS menus to for BreakPoints bar to get list of BreakPoints?
- Have you ever searched in VS menus for Immediate window?
- Have you ever searched in a VS for Solution explorer if its not in right side of editor?
The Quick Launch will helps you a lot to avoid these kind of simple and even some complicated setting with out remembering all those as visual studio is a vast and it contains tons of features.
Bu just typing, some related words in quick launch it would gives a result by clicking on that it would opens the required ones.
Few examples are mentioned below.
Refactoring:
Code Refactoring is also having its own importance while writing a code. Suppose if you have written some block of code as a initial code development. After certain moment, you have noticed that the same block of code will be required at some other location.
Then, Usually what you will do, Remove that block of code, create a method separately with that code then call that method in the required places where as desired.
The whole process will be managed by Visual studio Refactoring option.
You, Just need to do is only select the required code block, Right click and select the Refactoring option.
And then just click on "Extract Method" then it opens a popup like the below.
Now, By Clicking on "Ok" button then the code result will display is as follows.
Conclusion:
I hope the provided key notes on visual studio will help you to write code in a smart way with less pain.