Skip to the content.
Home | Blog | Book Reading |About | All Courses

Duplicating a line in Vi


Today I Learnt that, you can use

:t.

to duplicate the line on which your cursor is present

Use case

Usually, when working with existing code [ to either trace through the code, or debug it ] I would use the following keys to duplicate the current line on which my cursor is present

yyp

But now, with vim :t., its much easier

Helpful Tip

Recently, I was updating my log book where each line refers to works done on each day

Every day, a new entry gets added at the end of file.

While adding the data for today, I noticed that the data that I needed was already present in a line written 5 lines above the last line of the file

So, I moved the cursor to the existing line and typed

:t$

To duplicate the present line to the end of the file.