C# – Automatically call visual studio 2008 “sort using directives” on save

ccode formattingusing-directivesvisual studiovisual-studio-2008

Visual Studio 2008 got two great features for c#, which is called "sort using directives" and "remove unused using directives".

I'd like to call the "sort using directives" every time I format the code using ctrl+k,ctrl+d.

Or, even better, I would like to be able to reformat all c#-source files in a project, and call "sort using directives" for all source files.

How can I do this? Opening every cs-file by hand and typing these functions before every checkin is tedious!

Best Answer

You can do it all for a solution or project using "PowerCommands for Visual Studio 2008". After installation, you just need to right-click on a project or solution and "Remove and Sort Usings" is in the context menu.

EDIT: As noted in comments, there are also PowerCommands for Visual Studio 2010.