Geeks With Blogs

Brian Laird My garden isn't on facebook. Semicolon.

I love to keep my class files clean, and often times that means not using the suggested using statements that visual studio inserts for me based on the template. I love the Organize Usings functionality, especially Remove and Sort, but by default there isn't a keyboard chord setup for it.

When you visit the options for visual studio under Environment >> Keyboard, you'll see all of the possible commands. Typing "Organize" into the filter box will get to what we want.

Finding the command

Then we just need to assign a shortcut key. Luckily it didn’t take long for me to find a shortcut chord that was available, CTRL+R, CTRL+S. Hold the Control key and type R then S into the shortcut keys box and then click assign (assuming that no other command is using the shortcut in your environment).

Setting the keyboard shortcut

And there you have it. So anytime you make changes or if you just want to clean up a new class just type CTRL+R, CTRL+S and unused usings are removed and the rest are sorted.

Speaking of shortcuts, I’ll never understand why there isn’t one to close a file by default. I always assign ALT+C to the File.Close command so I can quickly cleanup several open files at a time.

If anyone has a better way (other than third party tools) I’d love to hear about it.

Posted on Friday, June 18, 2010 3:34 PM | Back to top

Comments on this post: Tip for Cleaning up Visual Studio Usings

# re: Tip for Cleaning up Visual Studio Usings
Requesting Gravatar...
Very useful. Thanks!
Left by steven on Jan 20, 2012 10:36 AM

Your comment:
 (will show your gravatar)

Copyright © Brian | Powered by: