jump to navigation

Tips : “Remove and Sort” Namespaces using Shortcut in Visual Studio December 4, 2010

Posted by Abhijit Jana in Tips and Tricks, Visual Studio.
Tags: , ,
trackback

While dealing with maintaining coding standard like stylecop warning fix with code, most of the time we need to remove unused namespaces and sort the namespaces.  We can do it easily from the context menu of  the code editor. There you have three different option for  “Organize Using” .  Either you can Remove Unused Usings , Sort Usings or we can do it together by selecting “Remove and Sort” .  Let’s see how we can make it more handy !

image

Even we can automatically fix this using some third party tools and addins. But it can be even very handy with in visual studio aswell,  if we can set some shortcut key for them. From Tools > Option, navigate to Keyboard tab. Search for “Edit.RemoveAndSort”  which command will to both remove unused usings and sort the usings, then set shortcut for the same, as I did with “Ctrl + Shift + W” , Click on “Assign” and Ok. you are done.

image

From next time you just need to press “Ctrl+Shift+W” to remove unused namespaces and sort them accordingly.

Even  you can set the same for “Sort Usings” ( “Edit.SortUsings” ) and “Removed Unused Usings” (“Edit.RemoveUsings”) .

Hope this will help save some of your time !

Thanks !

AJ

Comments»

1. Tweets that mention Tips : “Remove and Sort” Namespaces using Shortcut in Visual Studio « Abhijit's World of .NET -- Topsy.com - December 4, 2010

[...] This post was mentioned on Twitter by Daniel Vaughan and Abhijit Jana, Abhijit Jana. Abhijit Jana said: Tips : “Remove and Sort” Namespaces using Shortcut in Visual Studio: http://wp.me/ppvPE-vv [...]

2. Sudhanshu - January 6, 2011

thanks man…

3. msp.netdev - May 31, 2011

Thanks, very usefull ;-)

4. Ronnie - August 26, 2011

Thanks for this. Very helpful to men! :)

5. [Visual Studio] 削除と並び替えのショートカット « Exception Blend - September 20, 2011

[...] Abhijit’s World of .NET Tips : “Remove and Sort” Namespaces using Shortcut in Visual Studio Share [...]

6. Dyego Costa - January 2, 2012

Really helpful. Thanks!

7. teiva - January 16, 2013

Thanks. Very helpful (i assigne CTRL+Shift+O to remind me of eclipse shortcut ‘remove unused imports’)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,667 other followers

%d bloggers like this: