Formatting code allows you to improve the readability of the code, and as a result editing. The Visual Studio 2022 allows you to format both selected sections of code and the entire document. Let’s show how it works using an example of HTML code. Also this is applicable for any code like C#.
Format Entire Document – CTRL-E, DHot-Key: CTRL-E, D
Menu: Edit -> Advanced -> Format Document
Document Formatting Example – Before and After
Format Selection – CTRL-E, FHot-key : CTRL-E, F
Menu: Edit -> Advanced -> Format Selection
Selection Formatting Example – Before and After
There is also another interesting way to do formatting – Add ‘Format Selection’ In the Context Menu. You may interested in how to set conditional breakpoints in Visual Studio.