I've enabled the relativenumbers in Vim. I would like to automate the following operation.


that is to say:

  • mark the curr position in 'a'
  • move up or down by 'number' lines
  • yank current line
  • jump back to position 'a'
  • put line up or down

I'm looking for an easier way to perform the same. Is there one?



1 Answer 1


I guess I found the right way to do it with


for example


yanks 3 lines above.

  • 2
    If you want to duplicate a line, you could also use the :t command. To copy the 5th line above you under the current one, you would type: :-5t. To copy the 10th line under you above the current one, you would type: :+10t-1 The number before the :t command gives the position of the line you want to copy relative to the current one, while the number after it gives the position of the line under which you want to paste.
    – saginaw
    Feb 27, 2016 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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