3

I have two blocks of text and I want to merge them. However, the problem is that the blocks are not synchronous and I want to place one in front of the other completely. For example, suppose we have the following block of text:

aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa
aaaaaaaa

and the following block:

bbbbbbbb
bbbbbbbb
bbbbbbbb
bbbbbbbb

And I want to merge them thus:

aaaaaaaabbbbbbbb
aaaaaaaabbbbbbbb
aaaaaaaabbbbbbbb
aaaaaaaabbbbbbbb

I can't copy line by line because there are many lines in both files and they could be different.

4

Select all 'bbbb..' text using Ctrl-V (visual block selection mode), yank; then go to the last char of the first aaaa... string, hit Ctrl-V again; go down to the last aaaa ... string, while staying in the same column (so cursor is still on the last a character). You are still in block selection mode. Hit 'p' to paste.

  • I don't think this answer is right, as it deletes the last a in each row for me. – cbaumhardt Nov 8 '15 at 22:08
  • Hah, you're right :) But the idea is still the same - just do it in the other direction, and 'prepend' to the line using P. – VanLaser Nov 9 '15 at 9:44
3

Visual-block select (C-V) the text you want to prepend, then either yank/delete the text. Go to the first line and character of the text you want to prepend to, then press P (upper case P).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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