vimeditorkeyboard-shortcutsvi

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?


Solution

  • 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
    Shift + P to paste the copied or deleted text before the current line