Being the somewhat anal-retentive person that I am, I have always found it important to have all my using statements in an ordered sequence, and finally seem to have settled on plain alphabetical sorting.

A manual approach to this worked fine for me in Visual Studio 2003, since in any case I had to go to the top of my code file to insert a new using statement, and quickly determining where the new using statement would fit into the other using statements was quickly done, and then I could jump back to where I left off, and continue coding.

In Visual Studio 2005, this quickly became much more painful, due to the IDE's new smart tag feature, which allows me to add a using statement to my code if I type in a full type name in my code. This feature is very nice, and I quickly adopted it, but then found myself still jumping to the top of my code file for the sole purpose of sorting my using statements (did I say anal-retentive?).

Fortunately, Nicole Calinoiu has been so kind to develop a Visual Studio add-in which sorts the using statements: Bordecal.ImportsSorter. This tool sorts your using statements according to configurable rules. My installation is just configured to sort all using statements alphabetically, but the tool can also group the statements, if you, say, want all system imports to be on top no matter what.

I've used the tool for a couple of months, and the only quib I had with it was that by default there was no keyboard shortcut (just a context menu), and it wasn't possible to permanently assign one.

Finally it occurred to me to contact the author and request this feature, and less than a day later this fix was ready! I've now assigned Ctrl+u, Ctrl+s (my mnemonic for using, sort) to the tool, and it works just perfectly. Thanks, Nicole!

Skip to main content