Both of these options can do this on a per solution, project, document basis.
If you want to this via command-line, look at dotnet format. These all work better if you’ve got a good .editorconfig
that calls the style. You can have IntelliCode automatically generate one based on the project via Add -> New Item -> Editor Config (IntelliCode).
From: Greg Keogh via ozdotnet
ozdotnet@ozdotnet.com
Sent: Wednesday, April 12, 2023 11:03 AM
To: ozDotNet <ozdotnet@ozdotnet.com>
Cc: Greg Keogh <gfkeogh@gmail.com>
Subject: VS2022 format all files
Folks, is there a way to apply commands like Format Document and
Remove and Sort Usings to multiple C# files, perhaps all open files or all files in the project?
Web searches suggest it's not possible at the moment. I see an Extension for this which looks a bit flakey and I won't try it yet.
Taking this even further, I occasionally need to "beautify" C# code in hundreds of files in projects to fix things like indentation, tabs, usings and more fiddly things like removing excess blank lines, putting gaps between methods, etc.
That is, I want to bring code that is sometimes haphazardly formatted back to a vanilla format acceptable to typical developers.
Cheers,
Greg Keogh