How do I copy a line to another location without yanking?
Answer
:t {line-number}
Explanation
The :t (copy/transfer) command duplicates the current line and places it after the specified line number. It does not affect registers.
How it works
:t 0copies the current line to the top of the file:t $copies it to the end:t .duplicates the line below itself:t -1duplicates the line above itself
Example
:t 0 " Copy current line to top of file
:t . " Duplicate current line
:5t 10 " Copy line 5 to after line 10
Tips
:tdoes not modify any registers (unlikeyyp):'<,'>t $copies a visual selection to end of file:cois a synonym for:t- The source and destination can both use ranges and patterns
- Use
:t.to quickly duplicate the current line