'how to copy by specifying line numbers in vi

How can I copy by specifying line numbers in vi, e.g. lines 364-757? I tried searching for this but cannot find such a command.



Solution 1:[1]

yank those lines in register:

:364,757yEnter

if you want to copy those lines and paste to some certain line, t is your friend. for example:

:364,757t2Enter will copy those lines to under 2nd line.

if you want to copy them to right under your current line:

:364,757t.Enter

Solution 2:[2]

You can yank (copy in vim terms) from line 364 to line 757 by typing

:364,757y<enter>

Solution 3:[3]

Not sure if my answer is needed

but you can yank one line number by

:123y

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kent
Solution 2 ThanksForAllTheFish
Solution 3 Harman Nieves