Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically call visual studio 2008 "sort using directives" on save?

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!

like image 397
Sam Avatar asked Jan 16 '09 13:01

Sam


1 Answers

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.

like image 156
Jon Skeet Avatar answered Sep 22 '22 08:09

Jon Skeet