Starting from VS2022-Preview2, there is no need to additional extension to “format on-save”, you just run a customized code cleanup that contains “Format document” action on-save:
- Customize your cleanup profile to perform “Format document” action (if not already there), in
Analyze > Code Cleanup > Configure Code Cleanup
- Enable “Run code cleanup profile on save” in VS configuration
Tools > Options > Text Editor > Code Cleanup
Bringing Code Cleanup on Save To Visual Studio 2022 17.1 Preview 2
Unfortunately code cleanup setting is not included to .editorconfig
file neither to exported config file .vssettings
that could be shared across a team, maybe it will be included in the future.
Some feature requests related to this:
-
visual studio 2019 allow import and export Configure Code Cleanup profile
-
Provide a way to share Code Cleanup profiles as related to EditorConfig
-
Code Cleanup and EditorConfig