Lets say the cursor is at line N and we yank it with yy and we want to paste to 20 lines below the cursor is. Is it possible to do so without moving the cursor down like 20j, p, 20k? Tried 20p but it just pasted 20 duplicate lines. I can't find a solution after some googling, and I can't be the only one that need this.
What I want to do is yank (yy) the current line, paste to 20 lines below, go down one line (j), yank (yy) the current line, paste to 33 lines below, go down one line (j), yank (yy) the current line, paste to 41 lines below, go down one line (j), rinse and repeat
You can use the :co[py]
command:
:[range]co[py] {address} :co :copy
Copy the lines given by [range] to below the line
given by {address}.
So for the example given: :co .+20
would copy the current line 20 lines down.
If you are looking for a built-in command/option for pP
, there is no one. You can always press `` to go back your old position.
If you want to create custom mapping, there are many ways. E.g. write a function, write a custom command etc.
If you just want to automate some actions, like, for each line between 2-20, duplicate and copy to 5 lines below current line. you can consider to use :g
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With