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, D
Hot-Key: CTRL-E, DMenu: Edit -> Advanced -> Format Document
Document Formatting Example – Before and After
Format Selection – CTRL-E, F
Hot-key : CTRL-E, FMenu: 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.