How to setup ReSharper to call 'Sort usings' in class?
szkraszkra
ReSharper is a useful third-party code cleanup and style tool. DO use plural form for namespaces. DO add using inside namespace declaration. Please welcome the third release of ReSharper C this year! V2018.1 brought debug step filters and includes analyzer, while v2018.2 came with the initial C/CLI support and better understanding of C17 and C20 standards. The just released v2018.3 tunes literally every smart feature the product has, making them work more precisely on modern C code.
5 Answers
I will answer for my question.
Using shortcut from Resharper it's not best solution. Nice tool is CodeMaid it makes few nice cleanup's when saving file like with no shortcut key press:
- sorting usings alphabetically and remove unused
- deleting empty lines
This tool is complement for Resharper.
szkraszkra
![C# using inside namespace C# using inside namespace](/uploads/1/2/5/5/125536869/843005596.png)
Resharper (9) will sort usings if you run Code Cleanup, via menus or keyboard shortcut CTRL+E, CTRL+C
Fredrik StolpeFredrik Stolpe
Try using the Stylecop Resharper Plugin
Stylecop Rule SA1210: Using directives must be sorted alphabetically by the namespaces
will allow you to use a quick fix to sort them by pressing ALT+ENTER.Using Stylecop is good at helping you write clean code, but you may want to turn off some of the rules.
Piers MyersPiers Myers
You don't need ReSharper to do this. By Default the shortcut CTRL+E, R will remove (unused) and sort the using statements.
If you only want sorting or the shortcut isn't set on your instance of Visual Studio, go to:
- Tools-> Options.
- Environment -> Keyboard
- Search for 'Editor.ContextMenus.CodeWindow.OrganizeUsings'.
There are a few options there to play with.
ShahShah
This question already covers this:
The feature is in ReSharper 4.5. If you right click on the solution, there's a Cleanup Code... item, which allows you to apply a cleanup profile to the solution. You can create a new cleanup profile from the Code Cleanup node within ReSharper options, if you want a profile to just adjust the using directives.
Community♦
BexBex