Playing with keyboard shortcuts is very interesting and reduce the headache of using mouse again and again while programming with Visual Studio IDE. There are some very useful hot keys which can increase our productivity significantly.
So, I decided to share a list of visual studio keyboard shortcuts that are amazing and very helpful.
- While code review I found scattered and unaligned code many time which we all hate. I used CTRL+K+D for aligning it. The left side of my code is scattered, so first I selected the area of code and then applied CTRL+K+D.
- Use F12 to go to definition of class. Use CTRL- to go back.
- Resolve the classes and use CTRL+.
- Refactoring is very important. Use CTRL+R+M for extracting a method.
- Want to put few lines of code in try block. Try Ctrl + K + S.
It provides a lot of options.
- Ever tried selecting a rectangle code. Use ALT click drag.
- Lots of code in a single file. Use CTRL + M + O and CTRL + M + X in collapse/expand code groups like regions, methods.
- Lots of code and there are no groups. Use CTRL+M+H/CTRL+M+U.
- Create new Class using CLS and press TAB twice, or
- Create constructor using CTOR and press TAB twice.
- Create properties using PROP and press TAB twice.
- Create for loop using CTRL+K+S, then go to foreach and press Enter or TAB.
- Write full property definition that we used in earlier to C# 3.0, then use propfull, press TAB twice.
- Create switch block, use switch, press TAB twice
- Write our own custom exception class that should inherit from Exception class.
Exception press TAB twice.
- Write console.writeline, use cw, press TAB twice.
- Show the horizantal space by dot use CTRL+R, CTRL+W
- Remove the Horizontal space , CTRL+ K ,CTRL+ \
- Shifting the code left side use Shift +Tab
- Shifting code right side use , select the code and use Tab
This is not the complete list but very common ones that can be used a lot in our day to day coding.
I hope you liked this. Have a good day. Thank you for reading.