To duplicate a line in Vim, you can use the yy
command. This command stands for “yank” and will copy the current line to the clipboard. To paste the copied line below the current line, you can use the p
command.
For example, to duplicate the current line in Vim, you can do the following:
- Position the cursor on the line that you want to duplicate.
- Press
Esc
to exit insert mode (if you are in insert mode). - Type
yy
to copy the current line to the clipboard. - Use the
j
key to move the cursor down to the line below the current line. - Type
p
to paste the copied line below the current line.
Alternatively, you can use the dd
command to cut the current line and then use the p
command to paste it below the current line.
You can also use the :t
command to duplicate a line, like this:
- Position the cursor on the line that you want to duplicate.
- Press
Esc
to exit insert mode (if you are in insert mode). - Type
:t.
to duplicate the current line.
This will copy the current line and paste it below the current line.