In Visual Studio if you want to enforce consistent coding styles in a project or solution check out EditorConfig files. An EditorConfig file can be checked into source control and it overrides local VS settings which means all developers don’t need to change their settings to align.. AWESOME!!!
… and since VS 2019 16.10 EditorConfig files now have a user interface so we don’t need to edit the files directly.
To run the formatting options you need to format document via Edit-> Advanced -> Format Document or click Ctrl+K,Ctrl+D or by running code cleanup.
An example of what the interface looks like is below.
It’s not the most obvious function in Visual Studio but the run code cleanup button located at the bottom of our code files is very helpful.
It allows us to apply a number of ‘fixers’ to the file such as format document (as per EditorConfig file), sort usings, remove unnecessary usings and more together so we don’t have to run individual keyboard shortcuts.