Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vi Copy-paste without navigating to the line

Tags:

vim

vi

Is it possible for me to say the copy the contents at a specific line (x) and paste in the current line without actually needing to go to x.

Right now, I need to type :x<Enter>yy<C-o>p. I just wanted to see if this can be done more efficiently.

like image 615
user1595789 Avatar asked Jan 29 '14 15:01

user1595789


1 Answers

there is :t you can use.

for example if you are on line #77, and you want to copy line#7 below your current line, that is, #78, you just:

:7t.

after executing this, your cursor will be on line#78, the newly "pasted" line.

read :h :t for details, you may want to know the powerful :h range as well.

another advantage of :t instead of y/Y is, you keep " register untouched.

like image 130
Kent Avatar answered Sep 22 '22 21:09

Kent