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

How do I configure Vim to share the clipboard with my system?

Answer

:set clipboard=unnamedplus

Explanation

Setting clipboard=unnamedplus makes Vim's default yank and paste use the system clipboard. Every y, d, p command automatically goes through the system clipboard, so you can copy/paste between Vim and other applications seamlessly.

Options

" Use system clipboard for all yank/delete/paste
:set clipboard=unnamedplus

" Use primary selection (X11 middle-click paste)
:set clipboard=unnamed

" Use both
:set clipboard=unnamedplus,unnamed

What each setting does

Setting Effect
unnamedplus y/d/p use "+ register (system clipboard)
unnamed y/d/p use "* register (primary selection / macOS clipboard)
(empty) y/d/p use "" register (Vim-internal only)

Platform differences

  • Linux/X11: "+ is clipboard (Ctrl+C), "* is primary selection (mouse select)
  • macOS: "+ and "* are the same (system pasteboard)
  • Windows/WSL: "+ is the Windows clipboard

Check clipboard support

:echo has('clipboard')     " 1 if supported
vim --version | grep clip  " Look for +clipboard

Without clipboard support

If your Vim lacks clipboard support:

" Linux: use xclip as a workaround
vnoremap <leader>y :w !xclip -selection clipboard<CR>
nnoremap <leader>p :r !xclip -o -selection clipboard<CR>

" Or install vim-gtk3 / neovim for clipboard support

Tips

  • unnamedplus is the most commonly recommended setting
  • With unnamedplus, you no longer need "+y or "+p — plain y and p work with the system clipboard
  • Named registers ("a-"z) still work independently of the clipboard setting
  • Neovim always supports clipboard if a provider is installed (xclip, xsel, pbcopy, win32yank)
  • :checkhealth in Neovim shows clipboard provider status
  • Documented under :help clipboard

Next

How do I run the same command across all windows, buffers, or tabs?