You are not logged in.

#1 2012-01-27 08:22:14

awayand
Member
Registered: 2009-09-25
Posts: 398

[SOLVED] vim: marked text to be piped and read back in

I have a file in vim that looks like this:


a
b
c
d
e
f
g

I want to merge a few lines in vim with an external file "myfile.txt" that looks like this:

1
2
3

So the end result should look like this:

a
b
c
d 1
e 2
f 3
g

Here is what I tried:

Select the lines d, e, f using "V" (visual mode). Hit ":" to get vim to "mark" these lines' address. Then I tried "r! paste - myfile.txt".

I was hoping that the "!" would somehow pipe my marked lines as input into paste, but no dice. Anyone know what I am missing?

I don't want a sed solution, I just want to do the quick and dirty (and quite elegant, I might add) way from within vim using ":r!"...

Thanks a lot!

EDIT: got it, looks like I only need "!", no need for "r". thanks anyway!

Last edited by awayand (2012-01-27 08:27:43)

Offline

Board footer

Powered by FluxBB