Yank a particular line without moving the cursor — +12t.

On an occasion, I need to duplicate a previous line of code in a different area. I know…I should follow the DRY principle. But, sometimes its just one line. The non-vimist in me will move to the line, yank it (YY), move back to the line where I want to paste, and paste it. Wow, that is too much navigation.

From the VIM command line, this can be achieved much more easily. Assuming I am in relative line mode, if I want to duplicate line 12 lines down on the line where my cursor is, the command is +12t. .

Similarly if I want to copy actual line 5 (in a non relative line mode) to the line above the current cursor position: 5t-1.

You can use ranges as well. Super efficient once you know.

Thanks to Unix Stackexchange for the info.

Show your support

Clapping shows how much you appreciated Bill Christian’s story.