Playing with keyboard shortcuts is very interesting and reduces the headache of using the mouse again and again while programming with Visual Studio IDE. There are some very useful hotkeys 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 times which we all hate. I used CTRL+K+D to align 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 the 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 a few lines of code in the try block. Try Ctrl + K + S.
It provides a lot of options.
- Ever tried selecting a rectangle code? Use ALT and click drag.
- Lots of code in a single file. Use CTRL + M + O and CTRL + M + X in the collapse/expand code groups like regions, and methods.
- Lots of code and there are no groups. Use CTRL+M+H/CTRL+M+U.
- Create a new Class using CLS and press TAB twice, or
- Create a 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 the full property definition that we used earlier to C# 3.0, then use propfull, and press TAB twice.
- Create switch block, use switch, press TAB twice
- Write our own custom exception class that should inherit from the Exception class.
Exception press TAB twice.
- Write console.writeline, use cw, and press TAB twice.
- Show the horizontal space by dot using CTRL+R, CTRL+W
- Remove the Horizontal space, CTRL+ K, CTRL+ \
- Shifting the code left side use Shift +Tab
- Shifting code to 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 like this. Have a good day. Thank you for reading.