Automatically Remove and Sort Usings on Save in Visual Studio 2017

Manually removing and sorting Usings can become a tedious process when working with many classes and files. Handle this automatically when saving any file in Visual Studio 2017 using the Productivity Power Tools 2017 extension bundle installer, specifically the Power Commands extension. These can be installed directly by navigating to Tools | Extensions and Updates … in Visual Studio.

After installing the extension, go to Tools | Options | Productivity Power Tools | Power Commands. Check Remove and Sort Usings on save.

remove-and-sort-usings-on-save

Test this by editing a code file and saving (Ctrl+S). Any unused Usings should be automatically removed and existing ones sorted.

For ReSharper users, there is a chance that this setting does not work. This is a known issue. As a work-around, deselect Hide overridden VS menu items in ReSharper options.

Navigate to ReSharper | Options | Environment | Keyboard & Menus. Uncheck Hide overridden VS menu items.

hide-overridden-vs-menu-items

The Power Commands extension should be working again.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s