Mastodon hachyterm.io

Today I learned about the copy command (alias t):

:[range]co[py] {address}				*:co* *:copy*
			Copy the lines given by [range] to below the line
			given by {address}.

Let’s say we have a file like this:

1 line a
2 line b
3 line c
4 line d |

You are on line d (symbolized with the | as the cursor).

You want to copy from 1 to 3 (line a, line b, line c).

Type :1,3t., hit Enter and Vim will add the previous lines underneath the cursor.

t is a shortcut for the :copy command.

The . (dot) is for the current line. And 1,3 is the range you want to copy: from line 1 to 3.

The original tip (with relative line numbers) is from Mastering Vim.

I needed some more examples to understand the copy and the range in Vim, so I looked it up on Stackoverflow, too.

Further Reading