This is very simple in Visual Studio. Follow the below steps.
- Select the code you want to re-format.
- Press Ctrl-K
- Press Ctrl-F
The key combination Ctrl-K + Ctrl-F only works on selected text, so make sure you select the code you want to re-format before using it. You can easily reformat the entire code by pressing Ctrl-A Ctrl-K Ctrl-F.