Merge/Append two files and keep the same number of lines?
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?
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.
Thank you Alan, you’re a life saver :)
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
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.
@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.
@robert-carnegie Yeah, honestly this might be the easier way to do it, even though it is a bit of manual work.
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.
Thank you guys! Keyboard shortcuts seemed to work better for some reason. Finally got this to work :)