I am wondering what the way of copying a line and pasting it below my cursor in vi/vim might be?

Current workflow (copy line 21 and paste it below cursor): 21ggyy''p

Is there something shorter like: 21gyp

I used emacs avy (https://github.com/abo-abo/avy) to do these kind of things before

  • 1
    Here you go: :21t. Jun 11, 2018 at 10:37
  • also 21GYCTRL-Op
    – Mass
    Jun 11, 2018 at 14:28

1 Answer 1


I mean 21ggyy''p is pretty fast, but here's a simple ex command:

  • Act on line 21
  • t for copy ( :copy also works here)
  • . Is special for the current line. (:h :t)

You can also supply relative ranges for both the location and destination e.g. -5t+7 (copy the line 5 lines above the cursor to 7 below). Use :m instead of :t to move a line. Alternatively :21y to yank the line and paste with p

vim-easymotion seems to be similar to what avy is in emacs so you could also have a look at that.

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.