Home > Tutorial > Visual studio tips and tricks > Format your code using short cut keys

Format your code using short cut keys

Email | Print
Visual studio has a feature to format the source by using below different ways

1. To format source code, place the cursor in the code page and Press [Ctrl] + [E], [D]. This short cut keys would format/align entire page code. If you want to format the code for only selected portion then select the code and press [Ctrl] + [E], [F] or Select code portion then right click on the selected part as like below then select Format Selection, this would format only selected part from code page.

2. To comment a code, place the cursor in any line and press [Ctrl] + [K] + [C] keys, if you want to comment a block of code then select the specific portion of code in the visual studio editor and press [Ctrl] + [K] + [C] as like below.

3. To uncomment a code, place the cursor at commented line and press [Ctrl] + [K] + [U]. If you want to uncomment a block code then select commented block code and press [Ctrl] + [K] + [U].

4. Ctrl + M +O – Collapse, Ctrl + M +L - Expand.

« Cycle Clipboard Ring feature in Visual studio »
Like this tutorial? Bookmark and Share:

Latest Posts