A lot of times I'm in a situation similar to this:

1. <Line 1>
2. <Line 2>
3. <Line 3>
4. <Cursor is here>
5. <I want to copy line 1 here>

An easy solution is mm:1<CR>yy`mp - that is, make a mark at line 4, go to line 1, copy it, go back to the mark, and paste.

Is there a shorter/more fluid solution to this? I do this often enough that I'm happy to make a mapping for it.

2 Answers 2


Looks like a case for ex copy (:help :co or :help :t):


or, using your cursor's position:


This does not copy the line to the yank register, which might or might not be what you want.

  • I do not use ex copy enough, good suggestion.
    – jecxjo
    Apr 24, 2015 at 14:25

You could shorten it by not using marks and yank the line directly.


Command version of yank takes a {range} so select a line or a group of lines.

Additionally, the range value can be either absolute or relative. Lines above the cursor are negative distance and below are positive. So yanking two lines above is :-2y and yanking two lines below is :+2y.

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.