0

My cursor is on line 10. How can I yank line 5 and paste to lines 10,20,30,40, and 50?

I know :5 yank then navigate to each line and then P, how else can I do this?

1
5

You can use the :put command (well :put! for P). One problem would be that the line numbers will change as you paste additional lines, so:

  1. Work in reverse order:

    :5 yank | 50put! | 40put! | 30put! | 20put! | 10put!
    
  2. Or use :g with a pattern matching line numbers:

    :5 yank | :g/\v%10l|%20l|%30l|%40l|%50l/ put!
    

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