If I have file1.txt which contains the following:

Line 1.1;
Line 1.2;
Line 1.3;

and file2.txt with the following

Line 2.1;
Line 2.2;
Line 2.3;

I want to copy all the lines of file2.txt and paste it to file1.txt in a way that stays like this:

Line 1.1;Line 2.1;
Line 1.2;Line 2.2;
Line 1.3;Line 2.3;

how can I do it?


The lines can have some variation of character numbers like if file1 have

Cabo de Força MD9 1.5M NBR14136 3X0,50 – 5815;R$ 8,90;
Empire Cabo HDMI 1.4TV 3D M/M 2m Gold – 2304;R$ 13,90;
Filtro de Linha SMS 4 Tomadas 1,3M Bivolt 62328;R$ 33,90;

and file2 have:

Fonte Corsair CX600 600W CP-9020048-WW ATX 2.3 PFC Ativo; R$ 339,00;
Memória DDR4 Kingston HyperX Fury HX424C15FB/8 8GB 2400MHz; R$ 429,00;

Just as an example.

  • Do the lines always have the same number of characters? If the number of columns is fixed there's an easy solution using visual block mode... If it's not, can you edit the post to include examples with different number of columns?
    – filbranden
    Aug 29, 2020 at 17:13
  • With uneven line lengths I'd do it by adding some padding to the longest line in the target file, set virtualedit=block, ctrl-v to select and yank in the source file, then ctrl-v in the target file selecting the rightmost column (which ve=block allows) and put.
    – B Layer
    Aug 29, 2020 at 17:23
  • Man, absolutely no one looks for duplicates anymore do they. :D
    – B Layer
    Aug 29, 2020 at 17:33
  • Link to the question itself rather than jumping to my answer which is one of several: Add a block of text to end of lines
    – B Layer
    Aug 29, 2020 at 17:40

2 Answers 2


On a *nix system, I would use paste first:

%!paste - file2.txt

And then you have lots of options to get rid of the tabs. You could add | sed 's/<C-v><Tab>//g' to the end of the pipeline above, or use the (very similar!) command


which permits abbreviation as :%s/\t//g.

  • There's already an answer using paste in the page I linked.
    – B Layer
    Aug 29, 2020 at 17:32
  • @BLayer that there is; I didn't read all the comments. (And were it not for the date on that post, I would have been surprised I wasn't the one to write it!) Wonder if it's a good dupe.
    – D. Ben Knoble
    Aug 29, 2020 at 17:33
  • 1
    I put it up for a vote so we'll see.
    – B Layer
    Aug 29, 2020 at 17:35
  • @BLayer re dupes, i will if i can remember seeing one, or if im convinced one must exist. Otherwise not so much 🙃
    – D. Ben Knoble
    Aug 29, 2020 at 18:02
  • 1
    When I started (here but mostly Unix & Linux) I remember there being an emphasis on it. Now and then a person would even get "scolded" if they clearly answered without any effort to check. That's how my thinking about it was formed. :)
    – B Layer
    Aug 29, 2020 at 18:08
  1. Yank the second paragraph (e.g. yip).

  2. Visually select the first paragraph.

  3. Leave visual mode.

  4. Run this Ex command:

    let l = split(@", "\n") | *s/$/\=remove(l, 0)

It works even if the lines on which you want to append the lines of the second paragraph are not contiguous.

For example, suppose your first paragraph is:

Line 1.1;
Line 1.2;
Line 1.3;

Repeat the exact same steps; but in the fourth one, use this Ex command instead:

let l = split(@", "\n") | *s/^Line.*\zs/\=remove(l, 0)
                             only append text on lines starting with "Line"

Not the answer you're looking for? Browse other questions tagged or ask your own question.