How to duplicate a whole line in Vim?

How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/ Resharper or Ctrl+Alt+/ in Eclipse?

2
21

yy or Y to copy the line (mnemonic: yank)

or

dd to delete the line (Vim copies what you deleted into a clipboard-like “register”, like a cut operation)

then

p to paste the copied or deleted text after the current line

or

P to paste the copied or deleted text before the current line

Leave a Comment