views:

150

answers:

4

There is this option available in Visual Studio 2008.

Is there a similar option in Visual Studio 2005? Or something else that would accomplish such a task? An add-in, maybe?

+1  A: 

Resharper can remove the unused 'using' statements. I'm not 100% sure it can also sort them.

edosoft
+1  A: 

If you're cleaning up the files with unsorted using statements once (as opposed to having to deal with them on an on-going basis, perhaps because of a sloppy/uncooperative coworker?), and you are willing to use another tool for the job, there is another option.

I like using VS 2005 for its intellisense, but sometimes find the editor lacking in power compared to Emacs. I have Epsilon (an Emacs clone) which has the command sort-region, which takes the lines in the current selection and sorts them alphabetically. I can even type in a keyboard macro in Epsilon that:

  • Finds the first using statement in a file and starts the selection there.
  • Finds the last using statement in the file.
  • Sorts the lines between the first and last using statement.
  • Saves the file.
John Källén
+1  A: 

Resharper has a sort function. But it looks like all System usings are put on top, and then the rest alphabetically.

Also check this question also on optimizing usings with Resharper.

Gerrie Schenck
+2  A: 

If you've got Visual Assist, that's got a 'Sort Selected Lines' command that will do what you need.

Charles Anderson