We have seen how scripting basically works for indentation. It’s also possible to register commandline functions (The command line is bound to F7 by default, or invoke View > Switch to Command Line). We will consider a small example again: sort the selected text. /* kate-script * name: unused * author: foo bar * license: LGPL * version: 1 * kate-version: 3.0 * functions: sorter */ function sorter (){ if (view.hasSelection()) { var start = view.startOfSelection().line; var end = view.endOfSelection().line; var text = document.textRange(start, 0, end, document.lineLength(end)); var lines = text.split(“\n”); lines.sort(); text = lines.join(“\n”); view.clearSelection(); document.editBegin(); document.removeText(start, 0, end, document.lineLength(end)); document.insertText(start, 0, text); document.editEnd(); }} The header line functions:...
Read more →