Macro to move line up/down or selected text up down?

continuing with my edtiting pallete im tryng to build :)..I wonder if anyone knows of a macro where when launched will move the current line point is in up/down (using the up/down keys?)
if also text is selected and It can move that up down that would be even better :smiley:



I'm brand new to the KM world, so I don't have a macro for you, but to achieve this, I use key bindings.
You can add this to your ~/KeyBindings/DefaultKeyBinding.dict file:

// move line up (Control Command Up Arrow)
"^@\UF700" = (selectParagraph:, setMark:, deleteToMark:, moveLeft:, moveToBeginningOfParagraph:, yank:, moveLeft:, selectToMark:, moveLeft:);
// move line down (Control Command Down Arrow)
"^@\UF701" = (selectParagraph:, setMark:, deleteToMark:, moveToEndOfParagraph:, moveRight:, setMark:, yank:, moveLeft:, selectToMark:);

That doesn't work very well with selection though.

See here for more details and inspiration.



thx @maclm

very appreciated. Wonder if anyone knows how to achieve this actively within KM.



You can try it. The macro would have to do something like this:

  1. Select the whole line
    • Either triple-click (depending on the used app), or moving the cursor to the beginning of the line (โŒ˜โ‡  or โŒƒA) then select to the end of the line (โ‡งโŒ˜โ‡ข)
  2. Cut action
  3. Move cursor to the beginning of the next line (โ‡ฃ or โŒƒN)
  4. Paste action
1 Like

and add a Return at the end.
Thank you for the idea.