Visual Studio is an amazing IDE that have lots of functionality built in to that so that could save the time of the developer. As I have heard, except for Apple Xcode, there is no other IDE that could compete with Visual Studio. First point of attraction for me was the set of short cuts that I can use to save my time. In-fact it is Ruwan (my boss) who pulled me into using them and I started loving them.
I would mention here some of the most frequently used shortcuts by me in day to day coding. Of course you can change them to a way which you would like within visual studio and export as a file, so can import it and use it in another Visual Studio environment. The shortcuts I mention here are valid for C# selection as the Visual Studio environment.
- Code Formatting (Ctrl + K, D)
I think most of the IDEs has a short cut or a menu option to format the code written as it could be aligned. In Visual studio its just few key strokes away to format an entire file.
- Navigate Back (Ctrl + -) or Forward (Ctrl + Shift + -)
If you need to instantly work in couple of places by referring one with another, this is a useful short cut that could navigate you even within two projects without a mouse click.
- Navigate to Class, Method, Property Definition (F12)
This is another useful shortcut incase you need to explore the definition class and so on.
- Surround with (Ctrl + K, S)
Control statements such as if, else, for, while do while can be created for a particular location of the code with the above command. If you select multiple lines and press Ctrl+K, S then the set of lines will be surrounded with the statement we select.
- Copy(Ctrl +C) or Cut(Ctrl + X) or Paste(Ctrl + V) Lines of code
If you have used any word processing application, you know these commands very well. In Visual studio, just go for the line you need to cut or copy, and enter relevant commands without highlighting the whole line. This saves time on highlighting the lines and make your moves faster.
- Resolve (Alt + Shift + F10)
Imagine you writing a class name which's namespace is not added with a using statement in the file. Visual studio will prompt the class does not exist and you can right click --> Resolve and select the using to add it to the file. This is a long process. You can do resolving simply by using the above shortcut and save your time.
This is not only for importing namespaces but apply for all resolving scenarios such like creating a method stub, defining a property, renaming the method and apply to its references and so on.
- Find All References (Ctrl + K +R or Shift + F12)
Visual Studio 2013 Preview has some awesome features for this but in earlier versions if you need to find a property, class or a method that is reffered in other locations, you need to right click and select find all references. The command above does that easy and fast without any mouse move.
- Navigating to Previous(Ctrl + Shift + 2) or Next (Ctr + Shift + 1) Reference
Once the set of references are highlighted, you can navigate through the definitions easily using the above commands.
- Commenting(Ctrl + K, Ctrl +C) and Uncommenting(Ctrl + K, Ctrl + U)
Commenting and un commenting a particular line or a block of code is made easy with the above commands.
- Turn Next Character to Lower Case(Ctrl + U) and Upper Case(Ctrl + Shift + U)
Working up to good code standards measure the quality of the developer. In that case, managing camel case and pascal case is important. Rather than deleting and adding the same character or a sentence(not used at all) is a slower process. This can be speed up by the above comments. Even a sentence can be turned up or low by highlighting and using this command.
- Find(Ctrl + F) and Replace(Ctrl + H) Window
As same as a word processor, these commands can be used to open up the windows.
- Navigate to Line Number in Same File (Ctrl + G)
This is not much used since back and forward commands are available. But in case need to navigate to a specific line after reviewing all, this will be useful.
There are many apart from these such like Ctrl + Tab for moving to next window, Ctrl + Shift + B for building the application which is good to check whether your code changes have done something that fails application building. Knowing these and getting used to these shortcuts will give a good start to explore others. In case if you are uncomfortable with any of these commands, they can be changed by navigating to Tools --> Options --> Environment --> Keyboard.
It's great to know these.. Thanks for sharing :)ReplyDelete