Move selected block up & down

Help with writing and playing macros

Move selected block up & down

Postby sas2000 » Thu Nov 01, 2007 10:40 pm

Hi, I'm sorry if this macro already exists, but I was not able to find it on the forum.

I'm using these macros to move current line up & down, I'd like to do the same thing but with current selected text, may you help me ?, thanks !.
User avatar
sas2000
Newbie
 
Posts: 9
Joined: Sat Aug 05, 2006 11:00 pm

Re: Move selected up & down

Postby Mofi » Fri Nov 02, 2007 6:59 am

Is the selected text only a part of a line or is the selected text a block of entire lines?

Could you post a before and after example with a color what is selected?
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Move selected up & down

Postby sas2000 » Fri Nov 02, 2007 7:58 am

Mofi wrote:Is the selected text only a part of a line or is the selected text a block of entire lines?

The selected text is a block of entire lines.

So that it should work exactly as your macros for Move line up and down, but keeping selection.

Thanks for your help :!:
User avatar
sas2000
Newbie
 
Posts: 9
Joined: Sat Aug 05, 2006 11:00 pm

Re: Move selected block up & down

Postby Mofi » Fri Nov 02, 2007 4:32 pm

My macros for moving a line up or down are not written to work on wrapped lines. So whether my macros nor your version of the Line Up macro works correct in all cases on wrapped lines.

I have today updated my macro reference file with an additional appendix which commands depends on the word-wrap mode. SelectLine is one of these commands.

You can easily watch what happens when you run the macros on a file with active word-wrap mode and View - Show Line Endings also enabled. Even better is to make the steps in the macros manually. I mean

Edit - Select Line
Edit - Cut
Key DOWN or UP ARROW
Edit - Paste

Depending if the current displayed line has a line ending or not and the displayed line above or below has a line ending or not the result is correct or totally wrong.

Much more complex macro code would be necessary to let the macros Line Down and Line Up work correct in all cases with word-wrap mode on.

The block move up/down macros will be even more complicated when it should work also with active word-wrap mode correct.

Maybe I or any other user has an idea how to handle all the possible situations correct for the 4 macros. But now I have no time to think about this really not easy job.

Without word-wrapping moving a block with restoring the selection would not be too difficult, especially when the block is always smaller than 32.000 characters because than a simple Find Up "^c" could be used to restore the just moved selection.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Move selected block up & down

Postby sas2000 » Fri Nov 02, 2007 5:28 pm

I've tested your line up macro with WordWrap Off, but it doesn't work either (it only works ok the first time that you use it, second time line goes down :? ).

I think that it's really necessary that UE implement WordWrapOff command, thanks :!:.

Edit: Referenced Move Line Up macro modified on 2010-12-31 to be able to move current line up multiple times by executing the macro simply multiple times.
User avatar
sas2000
Newbie
 
Posts: 9
Joined: Sat Aug 05, 2006 11:00 pm

Moving multiple lines

Postby Pete Moss » Thu Dec 30, 2010 6:33 pm

UE has had the Move Line Up/Down function (Alt+Shift+Up/Down) as long as I've used it (v14). I submitted suggestions that this be expanded to multiple lines. If a block of lines are selected, Alt+Shift+Up/Down would move them all as a block. I just upgraded to v16 and was disappointed to see that this still does not work.

I sent IDM a message and got a reply that it works if I use Edit | Move Line Up/Down. I just tested it and it does not work on my computer.

Does this work for anyone? If so, how?

Thanks
Pete Moss
Basic User
Basic User
 
Posts: 11
Joined: Wed Mar 24, 2010 11:39 pm

Re: Move selected block up & down

Postby Mofi » Fri Dec 31, 2010 9:01 am

Moving a selected block with the commands Move Line Up/Down does not work with UE v16.30.0.1003.

But with 2 macros you can move either the current line or the currently selected block down or up by 1 line.

Please note that the macros work only with UE v14.00 or later because of macro commands MoveLineDown and MoveLineUp. Of course the commands could be replaced by my macros Move Line Down / Up (without the first 3 commands).

And the macros work only for blocks where the line termination of the last selected line is also selected, otherwise a blank line will remain after moving the block down / up.

Move Block Down (works also for a single line):

InsertMode
ColumnModeOff
HexOff
IfSel
Clipboard 9
Cut
Key DOWN ARROW
Key END
IfEof
"
"
Else
Key HOME
IfColNumGt 1
Key HOME
EndIf
EndIf
Paste
IfColNumGt 1
"
"
IfColNumGt 1
DeleteToStartofLine
EndIf
EndIf
UnixReOff
Find Up "^c"
ClearClipboard
Clipboard 0
Else
MoveLineDown
EndIf


Move Block Up (works also for a single line):

InsertMode
ColumnModeOff
HexOff
IfSel
Clipboard 9
Cut
Key UP ARROW
Key HOME
IfColNumGt 1
Key HOME
EndIf
Paste
IfColNumGt 1
"
"
IfColNumGt 1
DeleteToStartofLine
EndIf
EndIf
UnixReOff
Find Up "^c"
ClearClipboard
Clipboard 0
Else
MoveLineUp
EndIf


Reselecting the block with command Find Up "^c" works only for small blocks with up to 32.000 characters. And the macros work only for entire lines, not for long lines currently wrapped using soft wrap.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Macros

cron