How to replace searched lines with yanked line in vim? -


If I have a file:

  AAA / new replacement line AAA / old target Line random line random line BBB / old target line CCC / old target line   

In this example there are 4 substitutions, so the final file should end:

  AAA / new replacement line AAA / new replacement line random line random row AAA / new replacement line AA / new replacement line   

I have is an attempt to answer below, but to see this on your input Maybe I unaware of a more successful 'Wim golf' approach. Maybe I'm really dumb and there is a simple command for this.

Actually, this question is: If I am ranked in a register, the old copy line '?

Use 0y $ to yank your replacement line - This will not include the new line.

then use:

 % s /.* old target line. * / \ = "  

anonymous name to change target rows with the contents of the register, which will include the last evening.

Comments