One short and simple question, but I can't find a solution:
'Is it possible to sort the using directives alphabetically?'
Thank you in advance!
go to Options, search for USING. Select Advanced. Check box, "Place 'System' directives first when sorting using". Now a click on the right click context menu, Remove and Sort Usings, will order the using statements 'correctly'.
The using directive allows you to use types defined in a namespace without specifying the fully qualified namespace of that type. In its basic form, the using directive imports all the types from a single namespace, as shown in the following example: C# Copy. using System.
:: operator (C# reference) The global namespace is the namespace that contains namespaces and types that are not declared inside a named namespace.
Yes, it is. Just right click your directives, select Organize Usings --> Sort Usings
From documentation;
There are two ways to call the operation:
Main Menu - On the Edit menu, point to IntelliSense, point to Organize Usings, and then click Sort Usings.
Context Menu - Right-click anywhere inside the code editor, point to Organize Usings, and then click Sort Usings.
EDIT: In Visual Studio 2022, the same option called as Remove and Sort Usings
which you can also use Ctrl+R, Ctrl+G
shortcut for that.
(C#) On Visual Studio 2017 code editor right-click menu, it is now named "Remove and Sort Usings", not nested in any command. And have CTRL+R, CTRL+G shortcut out of the box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With