



I was recently asked if it was possible to turn a partial text selection inside the Komodo editor into a full line selection (similar to the way Vi's visual line selection works "Shift-V").
Indeed it is possible, though you'll need a Komodo macro to perform the functionality. Here is the Komodo JavaScript macro I came up with after a couple of minutes:
// To make the copy operation right here as well, uncomment the below lines.
//var clipHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
//clipHelper.copyString(String(scimoz.selText));
}
var scimoz = ko.views.manager.currentView.scimoz;
if (scimoz) {
var anchorPos = scimoz.anchor;
var currentPos = scimoz.currentPos;
// Line start/end positions will depend upon where the cursor is.
if (anchorPos < currentPos) {
scimoz.anchor = scimoz.positionFromLine(scimoz.lineFromPosition(anchorPos));
scimoz.currentPos = Math.max(scimoz.getLineEndPosition(scimoz.lineFromPosition(currentPos)),
scimoz.positionFromLine(scimoz.lineFromPosition(currentPos)+1));
} else {
scimoz.currentPos = scimoz.positionFromLine(scimoz.lineFromPosition(currentPos));
scimoz.anchor = Math.max(scimoz.getLineEndPosition(scimoz.lineFromPosition(anchorPos)),
scimoz.positionFromLine(scimoz.lineFromPosition(anchorPos)+1));
}
// To make the copy operation right here as well, uncomment the below lines.
//var clipHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
//clipHelper.copyString(String(scimoz.selText));
}Create a new JavaScript macro in your Komodo toolbox, with the above contents. You can then also assign the macro a specific keybinding to make it trigger when you need it to.