How to remove unused using namespaces

Yes you can right click on the page and from the menu select;

Organise Usings > Remove Unused Usings

Alternatively if you prefer shortcuts, please use;

Ctrl + R + G

I am using this all the time, to clean up code, and make code compilation quicker.

Or you can use PowerCommands to remove unused usings for entire projects


In Visual Studio 2017, I use this very simple key combinations: CTRL+R+G to remove unused imports/namespaces

Update:

In VS for Mac:

Unfortunately, there's no default key binding for this but you can always edit your preferences.

Visual Studio -> Preferences

enter image description here In my case, it is binded as +R+G


You can install an extension called: Productivity Power Tools 2015 (from Microsoft) and it has an option to automatically remove unused usings when you save your file. No more work needed after.

enter image description here

enter image description here


If you are using Visual Studio 2019, you can:

Right click your solution -> Analyze and Code Cleanup -> Configure Code Cleanup -> Create a profile (Remove & Sort usings) and then run it.

enter image description here enter image description here


Same answer as everyone else. If you are a keyboard ninja (Shift+F10 pops up contextual menu), use this:

Shift+F10,O,R


What do you call that special key for contextual menu? Instead of pressing Shift+F10 (my keyboard don't have that special key, that's why I uses Shift+F10), that is shorter:

whateverThatKeyCalled, O, R