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() {.开发者_Go百科..}
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() {...}
}
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
You can check the Open Source project NArrange, it can sort the using statements as well as all the members and classes in your files, and much more.
http://www.narrange.net/
The latest version is from 2009-12-05, so the project may not evolve any more, but it looks stable enough already.
MZ-Tools addin can do this.
Did you try codemaid? Is open source. There are others like ReSharper that are really good too.
精彩评论