Microsoft Visual Studio is an Integrated Development Environment (also called IDE usually) which can be used to develop applications in programming languages like C++, C#, F# and Visual Basic. There are different editions of Visual Studio. They include Visual Studio Express Edition, VS Professional, VS Ultimate. Most of the large software development companies use this IDE to develop their application programs. As Visual Studio is a Microsoft product it can only be installed and used in Windows Operating System. If you are a novice programmer and want to start development you can go ahead and grab the latest version of Visual Studio. There is also a free edition which can be used by individual programmers.
So, let's get started with the 5 tips and tricks as I promised you earlier.
Tips and Tricks
Surround With: This is a pretty cool and also a time saving feature. There can be situations when you have written a lot of code and then you remember that you need to put that into a try – catch block. So, you can always go ahead and type in try and put the curly braces and type out catch and all those things. But, here we are talking about shortcuts.
So, here's what you do. Select the portion of code you want to put inside try-catch block. Press Ctrl + K + S, this will bring up a combobox where you can type try and press Enter. This will automatically add even the catch block with it. You can use 'surround with' for other things like if, else, while, etc.
Format Document: Sometimes hundreds of lines of code can make your head spin if it is not properly formatted. Formatted code means that the code is correctly indented and a coding convention is applied. You may get some code that is poorly formatted or your code may become poorly formatted after a lot of coding.
So, you don't ever need to format the code line by line. You can happily press Ctrl + K + D to format the whole source code file. This is a great time saver. You can also choose to select a part of your code to format by selecting the portion of code and pressing Ctrl + K + F.
Commenting Code: Sometimes you may want some part of code to be used later but for the time being you want to keep it from executing. So, what do you do? can cut and paste that code in a separate place. You can also comment the specific portion of code.
So, here is the shortcut for commenting a portion of code. Select the portion of code that you want to comment. Now press Ctrl + K + C. The selected portion of code will be commented. That is as simple as that. You can also uncomment the code by pressing Ctrl + K + U.
Snippets Snippets are little words with which Visual Studio types in a code fragment for you. These can be useful if you are developing a large project and want to avoid repetition in your code. Snippets will save you a lot of time and you can use all the time you get to think about the business logic of your application. So, let's look at some snippets.
Instruction: After typing snippet provided below press Tab twice for the result to appear.
Refactor Rename: This feature can be useful to you if you want to change the name of a variable which has already been used in various places in the project. It is a tedious job to go and rename each instance where the variable is present.
You can use the option called Refactor Rename. For this select the word that you want to rename and right click on the word, go to Refactor and in that select Rename. Now type in the new name in the texbox provided. All the instances of the variable name will be updated.
There are many other shortcuts, but these are some of the major ones. I hope that these tips will help you speed up your development process using Visual Studio. Happy Coding.
Read Microsoft BizSpark - An opportunity for software startups
More articles: Visual Studio