Shortcut Keys In Visual Studio

Title

In this article, we are going to learn different types of shortcut keys available in the Visual Studio along with important points to remember for quality code.

So, let's get started with the shortcut keys,

1: CTRL +C

Select the piece of code and hold CTRL key and then press C to copy the piece of code, or just place the cursor on a given row of code without selecting anything and perform the same thing to copy the line of code.

2: CTRL +V

Hold CTRL key and press V to paste the copied code from the previous operation.

3: CTRL + K +C

Hold CTRL key and then press K and then C (Do it fast :P) to comment the selected rows of code. If you don't have any selected code then the row which holds the cursor will get commented.

4: CTRL +K +U

Hold CTRL key and then press K and then U to uncomment the selected rows of code. If you don't have any selected code then the row which holds the cursor will get uncommented.

5: CTRL +R +R

Place your cursor within variable which you want to rename, hold CTRL and press R then R(Do it fast :P). After this rename the variable and press ENTER to apply changes.

6: CTRL +K +D

Hold CTRL and press K then D to format your code. This will be useful in correcting the spacing. This will not add or remove extra rows wherever it is necessary.

7: Alt +UP DOWN(↑↓)

Hold the UP key and press UP and DOWN arrows to move the selected rows of code up or down.

8: CTRL + SHIFT + LEFTRIGHT (←→) 

Hold CTRl and press LEFT RIGHT arrows to select the whole word from your code.

9: CTRL + SHIFT RIGHT (→)

Hold CTRL and press SHIFT and RIGHT arrow to move the cursor faster throughout your code.

10: ALT + SHIFT + Arrow keys (←↑↓→)

Hold ALT and SHIFT keys and press arrow keys to move the cursor through your code to select specific part of your code spread on multiple rows(Its more precise than using mouse)

11: ALT + SHIFT + MOUSE LEFT Button

Hold ALT and SHIFT then drag your left mouse button to select a specific part of your code spread on multiple rows.

Now, We are going to learn few rules that need to follow while writing good quality code.

1: CURLY BRACKETS

Place Opening and Closing Curly brackets { } on new rows with nothing else on row.

2: Comments

You should always put one empty space after the // double slash comment or after /* slash star comment, to improve the readability.

3: Spaces

You should put free spaces before and after any operator that you are using to improve the code readability.

4: Free Rows

To improve the readability of code is to add empty rows between different blocks of code or between variables of different datatypes.

5: Datatypes

While creating your variables it's always good to put variables of same datatype together and not mix them with other data types. This will not affect how your code works but it will make your code look so much better and easier to understand.

6: Magical Numbers

Never use magical numbers in your code. These are the numbers that place randomly in your code and have no apparent reason to be there. Always extract those numbers into variables. Just by looking at your code you should be able to understand "what is what" and not wonder "From where it come here?"

7: Variables Naming

The names of your variables should always be concrete and descriptive, and when you name your variables they should always be in camelCase.

Summary

In this article, we learned different types of shortcut keys available in visual studio along with important points to remember for quality code. I hope you liked the article. Until Next Time - Happy Learning Cheers


Similar Articles