Automatically Remove and Sort Usings on Save in Visual Studio 2013

Automatically Remove and Sort Usings on Save in Visual Studio 2013

Sorting and Removing the unused namespaces is a general coding standard guideline.  We maintained this for all the files where we have then namespaces included.  You can do it easily from the “Organize Usings” context menu options,  or just enable a shortcut key like I explained in the Remove and Sort – Namespaces using Shortcut in Visual Studio tip. With the power of productivity tool, this is even more handy! Visual Studio can now take care of it automatically while saving the code file.

Once you have the productivity tool installed, you can find the “Remove and Sort Usings on Save” from the “Tools –> Options –> Productivity Power Tools –> PowerCommands –> Generals” .  You can find the below dialog options by just searching in the Visual Studio Quick Launch or Search with in the Option Dialog Control as well.

Remove and Sort Using on Save

With this settings enables, Visual Studio will automatically take care of removing the unused namespaces and sorting the remaining usings while saving the document.

And of course, don’t forget to check out the other Power Commands !

If you liked this tip, you may interested on looking  below listed productivity tool tips and tricks.

Edited / Note : This feature was available from the Visual Studio 2010 Power Tool onwards

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.