Vim: More Copying Tips
September 17, 2023 —
Gregg Szumowski
Blocks of lines can be copied in Vim using ranges, i.e., two numbers separated by a comma indicating the start and end of the block of lines.
Some Examples
To copy line 20-25, use:
:20,25yank
To copy five lines just above the cursor:
:-4,.yank
where the period (.) indicates the current line.
To copy five lines just below the cursor:
:.,+4yank