Move selected block up & down

Move selected block up & down

9
NewbieNewbie
9

    Nov 02, 2007#1

    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 !.

    6,681583
    Grand MasterGrand Master
    6,681583

      Re: Move selected up & down

      Nov 02, 2007#2

      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?
      Best regards from an UC/UE/UES for Windows user from Austria

      9
      NewbieNewbie
      9

        Re: Move selected up & down

        Nov 02, 2007#3

        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 :!:

        6,681583
        Grand MasterGrand Master
        6,681583

          Nov 02, 2007#4

          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.
          Best regards from an UC/UE/UES for Windows user from Austria

          9
          NewbieNewbie
          9

            Nov 02, 2007#5

            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.

            11
            Basic UserBasic User
            11

              Moving multiple lines

              Dec 30, 2010#6

              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
              I am running UE 16.30.0.1000 on WinXP (all updates applied).

              6,681583
              Grand MasterGrand Master
              6,681583

                Dec 31, 2010#7

                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.
                Best regards from an UC/UE/UES for Windows user from Austria