Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sci = ko.views.manager.currentView.scimoz;
- // If there's no block our cursor moves so we need to remember where it starts.
- var curLine = sci.lineFromPosition(sci.currentPos);
- ko.commands.doCommand("cmd_blockSelect");
- if (sci.selText == sci.text) {
- // We have just a single line selected
- sci.gotoLine(curLine);
- sci.vCHome();
- sci.lineEndExtend();
- var line = sci.selText;
- line = line.replace(new RegExp("{ ", "g"), "{\n\t")
- .replace(new RegExp("; ", "g"), ";\n\t")
- .replace(new RegExp("\t}", "g"), "}");
- sci.replaceSel(line);
- } else {
- // We have a block selected
- var line = sci.selText;
- line = line.replace(new RegExp(" ", "g"), "")
- // We need a negative look-ahead so we don't erase
- // the first bracket's indentation
- .replace(new RegExp("\t(?![{\t])", "g"), "")
- .replace(new RegExp("\n", "g"), " ");
- sci.replaceSel(line+"\n");
- sci.lineUp();
- }
Add Comment
Please, Sign In to add comment