Can I paste multiple lines into multiple lines?

Can I paste multiple lines into multiple lines?

20
Basic UserBasic User
20

    Dec 15, 2006#1

    What is the easiest way to achieve this? I really appreciate any help and I searched the forum so sorry if this has been answered. :?

    Here is an example of what I am wanting to do.

    This is copied into my clipboard
    xxxxx
    xxxxxxx
    xxxxxxxx
    xxxxx

    This is my text file
    oooo
    oooooo
    ooooooooo
    oooooo

    This is the result
    xxxxx
    oooo
    xxxxxxx
    oooooo
    xxxxxxxx
    ooooooooo
    xxxxx
    oooooo

    6,602548
    Grand MasterGrand Master
    6,602548

      Dec 15, 2006#2

      No! This is not possible directly.

      But you could do that with a macro. The macro must first copy via a user clipboard everything from destination file from current cursor position till end of the file to a temp file. Then it pastes at top of the temp file the lines you want to insert. Next it merges the lines at top of the file as explained by you. Last it selects everything in the temp file (merged lines + possible unmodified rest of the destination file content) and pastes it over the still selected content in the destination file.
      Best regards from an UC/UE/UES for Windows user from Austria

      20
      Basic UserBasic User
      20

        Dec 15, 2006#3

        Can you make one for me?

        haha just kidding I know that's probably to much to ask.
        Thanks A Lot for explaining that to me. I will try to make a macro to do this.
        :)

          Dec 15, 2006#4

          Ok, I made the macro work up to the point where you say "it merges the lines at top of the file".

          How do I merge them? Sorry I am totaly new to ultraedit. Thank you for your time.

          6,602548
          Grand MasterGrand Master
          6,602548

            Dec 17, 2006#5

            You have not written which version of UltraEdit you use and so I don't know if you are affected by the problem described at Problem with Previous Window/Tab Command. So I was forced to write a version which will also work when the most right tab gets the focus when closing the temp file instead of last used window.

            I describe the macro so you and other interested users which need line merging can adapt it, if this is necessary.

            First the macro pastes the content of the current clipboard into a new ASCII file. A Unicode file cannot be used currently (UE v12.20b) because IfEof is not working on a Unicode file.

            If the last line of the clipboard content has no line termination, insert it.

            Next insert a new line with the special marker character ». It's not important which character is used as marker character. It's only important that this character never exists in either the clipboard content or the destination file.

            Next the macro goes to top of the file and checks if there is the marker character. If this is true, the clipboard was empty and so nothing is to do for the macro.

            Back at bottom (end) of the temp file the last used window before macro start is selected, the cursor is moved there to start of current line and from that cursor position to the end of the file everything is selected and copied to user clipboard 9.

            Again check for line termination of last line and insert it, if it is missing.

            Next the cursor is moved up by one line. If this is the line starting with the marker character, nothing was copied before into clipboard 9 because maybe the cursor was already at end of the destination file. So there is nothing to merge and only the content of the clipboard active before macro start must be appended at the end of the destination file and then the temp file can be discarded.

            If there was really at least 1 line copied from the destination file to the temp file, then move the cursor to the marker character and delete the line termination there (= merge marker line with first line from the destination file).

            At top of the temp file now the line merging can start. The first line should be the line from the clipboard. So move the cursor down to start of second line from clipboard or later to second line of the rest of the initial clipboard content. If there is the marker character, nothing is to merge anymore, for example if the initial clipboard has contained only 1 line or there are less lines in the initial clipboard as there are lines below current cursor position to end of the destination file. So delete the marker character and exit the loop.

            If the line is not starting with the marker character, select everything from current cursor position - at first loop run this is the second line from the initial clipboard content - to the marker character with including it and cut it to user clipboard 9. The result is that the cursor is now at first line of the unmerged lines from the destination file.

            Set a bookmark on this line and move the cursor one line down.

            If the end of the file is reached now, the rest of the destination file has less lines than the initial clipboard. So there is nothing to merge anymore and only the rest of the initial clipboard content must be appended to the already merged lines. After deletion of the marker character and clearing the bookmark, exit the merging loop.

            If end of file is not reached, insert here the content of user clipboard 9 which has 1 line fewer than on last loop run (Key DOWN ARROW - you know). Move the cursor back to the bookmarked line, clear it and move the cursor down once to the first line of the remaining clipboard content to merge.

            So at every loop run the content from the initial clipboard is decreased by 1 line and the cursor is moved 1 line lower in the unmerged lines from the destination file.

            The rest is simple. Select everything in the temp file and paste it over the still existing selection in the destination file. Then delete the temp file, clear user clipboard 9 and switch to the Windows clipboard.

            That's it.

            Why is always about 5-10 times more time needed to explain a macro than developing it?

            InsertMode
            ColumnModeOff
            HexOff
            NewFile
            Paste
            IfColNumGt 1
            InsertLine
            EndIf

            "
            Top
            IfCharIs "»"
            CloseFile NoSave
            ExitMacro
            EndIf
            Bottom
            NextWindow
            Clipboard 9
            Key HOME
            IfColNumGt 1
            Key HOME
            EndIf
            SelectToBottom
            Copy
            PreviousWindow
            Paste
            IfColNumGt 1
            InsertLine
            EndIf
            Key UP ARROW
            IfCharIs "»"
            DeleteLine
            SelectToTop
            Copy
            NextWindow
            Paste
            PreviousWindow
            CloseFile NoSave
            ClearClipboard
            Clipboard 0
            ExitMacro
            EndIf
            Find Up "»"
            Replace "»"
            Key DEL
            Top
            Loop
            Key DOWN ARROW
            IfCharIs "»"
            Key DEL
            ExitLoop
            EndIf
            StartSelect
            Find Select "»"
            Cut
            EndSelect
            ToggleBookmark
            Key DOWN ARROW
            IfEof
            Paste
            Key BACKSPACE
            PreviousBookmark
            ToggleBookmark
            ExitLoop
            EndIf
            Paste
            PreviousBookmark
            ToggleBookmark
            Key DOWN ARROW
            EndLoop
            SelectAll
            Copy
            NextWindow
            Paste
            PreviousWindow
            CloseFile NoSave
            ClearClipboard
            Clipboard 0

            A line merging could be done much faster using column mode and regular expression replaces. But this solution depends extremly on the content of the destination file and so it would be very hard to write a general macro which uses the faster column mode method.
            Best regards from an UC/UE/UES for Windows user from Austria

            20
            Basic UserBasic User
            20

              Dec 25, 2006#6

              Wow, Thanks a lot Mofi!!!!!!