#Region "Sub SortSelectionAndSmartFormat" ' Sortiert und formatiert die aktuelle Auswahl. Sub SortSelectionAndSmartFormat() If (DTE.ActiveDocument Is Nothing) Then Exit Sub End If If (DTE.ActiveDocument.ReadOnly) Then Exit Sub End If Dim currentTextSelection As TextSelection currentTextSelection = DTE.ActiveDocument.Selection If (currentTextSelection.TextRanges.Count = 1) Then Exit Sub End If If (DTE.UndoContext.IsOpen) Then DTE.UndoContext.Close() End If Try DTE.UndoContext.Open("SortSelectionAndSmartFormat") currentTextSelection.SmartFormat() Catch End Try Try Dim currentLines() As System.String = Split(currentTextSelection.Text, vbCrLf) System.Array.Sort(currentLines) currentTextSelection.Delete() For Each i As System.String In currentLines If Not i = System.String.Empty Then currentTextSelection.Insert(i.Trim(vbCrLf) & vbCrLf) End If Next DTE.UndoContext.Close() Catch End Try Exit Sub End Sub #End Region