In Visual Studio 2019 how can I remove unused usings on format document?
I have found instructions for previous versions of Visual Studio (Go to Tools > Options > Text Editor > C# > Code Style > Formatting.). I don't see that in Visual Studio 2019.
Shift + Alt + O will take care of you. If you're a heavy visual studio user, you can simply open your preference settings and add the following to your settings.
Go to Tools > Options > Text Editor > C# > Code Style > Formatting. It has an experimental Format Document Settings where you can have Visual Studio clean up your code. Two of the options are to "Remove unnecessary usings" and "Sort usings". Check these two and you're good to go!
In Visual Studio 2019 you can remove unused usings with the Code Cleanup command:
And running code cleanup also formats the document.
CTRL + K + E Will sort and remove your unused usings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With