My cursor is on line 10. How can I yank line 5 and paste to lines 10,20,30,40, and 50?
:5 yank then navigate to each line and then
P, how else can I do this?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
You can use the
:put command (well
P). One problem would be that the line numbers will change as you paste additional lines, so:
Work in reverse order:
:5 yank | 50put! | 40put! | 30put! | 20put! | 10put!
:g with a pattern matching line numbers:
:5 yank | :g/\v%10l|%20l|%30l|%40l|%50l/ put!