Welcome, guest | Sign In | My Account | Store | Cart

This Komodo macro moves the line containing the caret (cursor) up one line, and then puts the caret at the start of that line in its new position. Put the macro in your toolbox, and bind it to Ctrl-Shift-UpArrow (unused in the default Komodo keybinding set) to get the same functionality as in some other popular editors).

JavaScript, 14 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
if (komodo.view && komodo.view.scintilla) { komodo.view.scintilla.focus(); }
var scimoz = ko.views.manager.currentView.scimoz;
if (scimoz.lineFromPosition(scimoz.currentPos) == 0) {
    return;
}
scimoz.beginUndoAction();
try {
    scimoz.lineCut();
    scimoz.lineUp();
    scimoz.paste();
    scimoz.lineUp();
} finally {
    scimoz.endUndoAction();
}

This macro won't do anything when the caret is on the first line of a buffer.

1 comment

Adam 10 years, 5 months ago  # | flag

Just a FYI to anyone looking here. This: http://community.activestate.com/forum/move-line-move-line-down-macros seems to be simpler and work better, has a macro for doing line or selection. Just need to change the komodo.assertMacroVersion(2); to: komodo.assertMacroVersion(3);