does anyone know a way to sort the functions of a class in the editor (c#) alphabetically? i.e.
public class Foo
{
public void B() {...}
public void D() {...}
public void A() {...}
}
After sorting the class should look like
public class Foo
{
public void A() {...}
public void B() {...}
public void D() {...}
}
Select Edit from the menu bar. Select Intellisense > Sort Usings. You can also configure different settings for using directives in Tools > Options > Text Editor > C# > Advanced.
You can easily organize your using statements. Simply right-click anywhere in the editor to get the context menu, choose Organize Usings, and then Remove, Sort, or Remove And Sort.
Create this macro.
Select the text to sort, and run the macro.
Sub SortSelectedText()
Dim Selection As TextSelection = DTE.ActiveDocument.Selection
Dim Lines() As String = Selection.Text.Replace(Environment.NewLine, Chr(13)).Split(Chr(13))
Array.Sort(Lines)
DTE.UndoContext.Open("Sort Lines")
Selection.Delete()
Selection.Insert(String.Join(Environment.NewLine, Lines))
DTE.UndoContext.Close()
End Sub
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