Move selected lines Up or Down

Hi, I’ve made an action to move the selected lines up or down, you can download the main action here.

But you will also need this two actions Move Line Up and Move Line Down.

You need them beacause the main action just receives the lines you want to swap.

Hope this helps

For modifications

If you want to modify this action theres only one drawback, in my script you can only swap lines that are adjacent. I made it this way because it was easier to check for errors.

It can be modified to swap any two lines in the editor, you just need to make sure to check for cases in witch the text will be moved inside the other range. That caused problems for me.


If you want to call the action with your own action in requires a templateTag named ’swap-lines’ that need to contain the index and range of both of the full lines you want to swap encoded in the following way:

“4-5,9-3”

Where 4-5 means the second line starts in index 4 and has a length of 5 and the next line starts at index 9 with a length of 3

Keep Selection

This action keeps the same text selected when you swap to adjacent lines, it does that by receiving the selected line in the first parameter.

If you want to swap two lines and non of them are selected, you would need to modify the selection process