How to setup ReSharper to call "Sort usings" in class?
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.
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.
Resharper (9) will sort usings if you run Code Cleanup, via menus or keyboard shortcut CTRL+E, CTRL+C
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.
This question already covers this:
Remove unused Usings across entire assembly
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.
© 2022 - 2024 — McMap. All rights reserved.