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

How do I copy and paste to the system clipboard?

Answer

"+y and "+p

Explanation

The "+ register is linked to the system clipboard. Using "+y copies to the clipboard and "+p pastes from it.

How it works

  • "+yiw copies a word to the system clipboard
  • "+yy copies a line to the system clipboard
  • "+p pastes from the system clipboard
  • Requires Vim compiled with +clipboard support

Example

To copy a paragraph to the system clipboard for pasting in another app:

"+yip

To paste text copied from a browser:

"+p

Tips

  • "* is the selection register (X11 primary selection on Linux)
  • :set clipboard=unnamedplus makes all yanks go to the system clipboard
  • Check clipboard support with :echo has('clipboard')
  • In some terminals, <C-S-v> also pastes from system clipboard

Next

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