How to Copy and Paste in Vim

Vim calls copying "yanking." You yank text into a register with y, then put it back with p. No mouse required.

Steps

  1. Yank a whole line. In Normal mode, place the cursor on the line and press yy (or Y) to copy it.
  2. Yank a word. Press yw to yank from the cursor to the start of the next word.
  3. Paste after the cursor. Press p to put the yanked text after the cursor, or below the current line.
  4. Paste before the cursor. Press P to put it before the cursor, or above the current line.
  5. Copy a precise selection. Press v, move to extend the highlight, then press y to yank exactly what you selected.

In the Vim Browser Editor

All of these work in the Vim Browser Editor. Deleting (d, dd, x) fills the same register, so you can cut with dd and paste it back with p.

Try it in the editor

Related how-tos

Advertisement