• Login
Community
  • Login

Merge/Append two files and keep the same number of lines?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 4 Posters 3.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    TorQue MoD
    last edited by TorQue MoD Jan 8, 2022, 11:53 AM Jan 8, 2022, 11:51 AM

    I have two files, both with 100 lines. I want to combine them so that the line numbers remain the same. IE File 1: Line 1: says Good and File 2: Line 1: says Dog. When I combine them, I get a 3rd file that says Good Dog on line 1. Is this possible?

    Thanks!

    A 1 Reply Last reply Jan 8, 2022, 12:55 PM Reply Quote 0
    • A
      Alan Kilborn @TorQue MoD
      last edited by Jan 8, 2022, 12:55 PM

      @torque-mod

      Yes, install the BetterMultiSelection plugin and make sure it is enabled.

      In file 2, hold the Alt key down while selecting all the text in the file with the mouse, starting from the very top and dragging down with the mouse to the end of the last line. Press Ctrl+c.

      In file 1, hold the Alt key and do the same selection operation as file 2 (but don’t press Ctrl+c). Press the End key followed by the Ctrl+v key.

      Note to others: Trying to keep this as simple as possible for someone that might not be familiar at all with column-block-selects.

      T 2 Replies Last reply Jan 8, 2022, 11:10 PM Reply Quote 3
      • T
        TorQue MoD @Alan Kilborn
        last edited by Jan 8, 2022, 11:10 PM

        @alan-kilborn
        Thank you Alan, you’re a life saver :)

        1 Reply Last reply Reply Quote 1
        • R
          Robert Carnegie
          last edited by Jan 9, 2022, 6:13 PM

          I’d probably do this in a spreadsheet - I am a database programmer but if you only need to do something once, then crude is good. Something like perl would do it, too. True, spreadsheets are meant for numbers, and they tend to treat their inputs as numbers - or dates.

          The spreadsheet method probably would be:
          Paste text of one file (“good”) in column A.
          Paste the second file (“dog”) in column B
          Write a formula combining them in column C i.e. =A1 & " " & B1
          (“good dog”)
          Copy that down 100 lines.
          Copy column C - as values, not as the cell formula - into column D, then delete A, B, C. Or just paste back into Notepad++ from column C.

          T 1 Reply Last reply Jan 11, 2022, 8:13 AM Reply Quote 0
          • T
            TorQue MoD @Alan Kilborn
            last edited by TorQue MoD Jan 11, 2022, 8:12 AM Jan 11, 2022, 8:09 AM

            @alan-kilborn Actually, I tried this and it just added the text to the end of the last line and then created new lines as you would expect with a normal Copy and Paste command.
            Was holding down ALT while you drag-select supposed to do something? I’ve got Better Multi Selection enabled but it still didn’t work. Also, I’m confused because when you press the END key after ALT selecting the text in Doc 1, it deselects everything. Not sure what this was supposed to do but your instructions were so specific I thought It’d work.

            E 1 Reply Last reply Jan 11, 2022, 10:50 AM Reply Quote 0
            • T
              TorQue MoD @Robert Carnegie
              last edited by Jan 11, 2022, 8:13 AM

              @robert-carnegie Yeah, honestly this might be the easier way to do it, even though it is a bit of manual work.

              A 1 Reply Last reply Jan 11, 2022, 1:03 PM Reply Quote 0
              • E
                Ekopalypse @TorQue MoD
                last edited by Ekopalypse Jan 11, 2022, 10:50 AM Jan 11, 2022, 10:50 AM

                @torque-mod

                1st - press shift+alt+downarrow to mark the column
                2nd - press shift+end to select the lines
                3rd - ctrl+c to copy
                4th - create a column like in 1st in the other tab
                5th - press end to let it jump to the end and press spacebar
                6th - press ctrl+v

                ONLY possible with BetterMultiSelection plugin installed.

                T 1 Reply Last reply Jan 19, 2022, 8:29 PM Reply Quote 4
                • A
                  Alan Kilborn @TorQue MoD
                  last edited by Jan 11, 2022, 1:03 PM

                  @torque-mod

                  @Ekopalypse 's instructions are equivalent to my original, except he uses keyboard commands and I used the mouse. Of course, his is better because he shows a video of it working.

                  1 Reply Last reply Reply Quote 1
                  • T
                    TorQue MoD @Ekopalypse
                    last edited by Jan 19, 2022, 8:29 PM

                    @ekopalypse
                    Thank you guys! Keyboard shortcuts seemed to work better for some reason. Finally got this to work :)

                    1 Reply Last reply Reply Quote 2
                    • A Alan Kilborn referenced this topic on Feb 2, 2023, 4:17 PM
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors