PASSWORD RESET

Your destination for complete Tech news

How to duplicate a line in vim?

1.57K 0
< 1 min read

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:

  1. Position the cursor on the line that you want to duplicate.
  2. Press Esc to exit insert mode (if you are in insert mode).
  3. Type yy to copy the current line to the clipboard.
  4. Use the j key to move the cursor down to the line below the current line.
  5. 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:

  1. Position the cursor on the line that you want to duplicate.
  2. Press Esc to exit insert mode (if you are in insert mode).
  3. Type :t. to duplicate the current line.

This will copy the current line and paste it below the current line.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.