summaryrefslogtreecommitdiffstats
path: root/kate/scripts/sort.js
blob: 41f2145fbd0f0776d3defab5ca4a41a52de73a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if( view.hasSelection() )
{
    start = view.selectionStartLine;
    end = view.selectionEndLine;

    txt = document.textRange( start, 0, end, document.lineLength( end ) );

    repl = txt.split("\n");
    repl.sort();
    txt = repl.join("\n");

    view.clearSelection();

    document.editBegin();
    document.removeText( start, 0, end, document.lineLength( end ) );
    document.insertText( start, 0, txt );
    document.editEnd();
}