vimtricks.wiki Concise Vim tricks, one at a time.

How do I copy selected text to the clipboard in visual mode?

Answer

y (in visual mode)

Explanation

In visual mode, pressing y yanks (copies) the selected text into the default register. You can then paste it elsewhere with p.

How it works

  • Select text with v, V, or <C-v>
  • Press y to yank the selection
  • The cursor returns to the start of the selection
  • Paste with p (after cursor) or P (before cursor)

Example

Select a paragraph with Vip, press y to copy it. Move to the target location and press p to paste.

Tips

  • "+y yanks to the system clipboard
  • "ay yanks to named register a
  • After yanking, the selection is stored in both " and 0 registers
  • gv reselects the yanked area if you need to see it again
  • Visual yank is more intuitive than operator-based yiw for beginners

Next

How do you yank a single word into a named register?