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
"+yiwcopies a word to the system clipboard"+yycopies a line to the system clipboard"+ppastes from the system clipboard- Requires Vim compiled with
+clipboardsupport
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=unnamedplusmakes 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