Sublime Forum

Moving a line to some ancor / line with a pattern

#1

Hi All,

I’m looking for a package/plugin/macro, which moves the selected line/text just under another line with a predefined pattern.
For example, there is a text:

abc
PTRN
def
qwe
selected_line

The ‘PTRN’ in the above example, is a pre-defined pattern.
So, if I select the selected_line in the above example and press some keys combination, the selected_line should move just under the PTRN line.
Here is the new text:

abc
PTRN
selected_line
def
qwe

Is this possible to write such Plug-In / Macro? Does it probably already exist?

Thank you!

0 Likes

#2

You can just keep the cursor on the line that contains selected_line and then press ctrl + shift/up or down to move that line up or down.

0 Likes

#3

" press ctrl + shift/up or down to move that line up or down" - OK, this is a simple case…
But, if I’d need to move the line let’s say 100 lines up until reaching the Text Anchor like ‘PTRN’?
Actually the trick, which I’m looking for, is staying on the same place (cursor is not moving), but sending the selected text to the place where predefined Text Anchor sits.
Hopefully I explained myself…

0 Likes