dodekja
dodekja

Reputation: 565

Is there an option to remove unused references on save in Visual Studio 2022?

Is there an option to remove and sort usings automatically on save for the current document? This used to be provided by the Power Commands for Visual Studio extension. Is this available somewhere in the Visual Studio 2022 options? Or is provided by some other extension?

I tried searching in the Tools>Options. And also searched the web for a while, but could not find a solution.

Upvotes: 7

Views: 13437

Answers (1)

Jimmy
Jimmy

Reputation: 28456

This can be done with the Code Cleanup feature. Starting in 17.1 Preview 2, this can be triggered on save. See the announcement at https://devblogs.microsoft.com/visualstudio/bringing-code-cleanup-on-save-to-visual-studio-2022-17-1-preview-2/

On versions prior to that, there is an extension that works with either VS2019 or VS2022 called Code Cleanup On Save

Upvotes: 14

Related Questions