0

If I want to copy and paste the next 5 lines and paste those 5 lines below the next 5 lines, I would do 5yy5jp. How would I use command to say something like 5yyp to paste the next 5 lines and automatically jump down to the beginning of the pasted text?

Example:

Line 1
Line 2
Line 3

to

Line 1
Line 2
Line 3

Line 1
Line 2
Line 3
  • There's quite a number of possible approaches, but which ones are valid depend on what's around what you're trying to yank and paste. Could you provide some examples including what you start with and the end result that you expect? Be sure to include any relevant variations, for instance, are are any blank lines in the block that you are yanking, or is there a blank line separating the yanked block from the pasted block? – ZeroKnight Apr 21 at 22:20
  • I've added an example. – StevieD Apr 21 at 22:26
  • OK, I figured it out. I want to 3yygP. – StevieD Apr 21 at 22:35
  • Keep in mind that will only work if your cursor is on the first line of the block that you wish to yank. It also doesn't leave a blank line as in your example. – ZeroKnight Apr 21 at 22:44
  • Yeah, right. So I came up with nnoremap cp yygPko<esc>j – StevieD Apr 21 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.