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

How do I paste text from the system clipboard into Vim?

Answer

"+p

Explanation

The "+p command pastes the contents of the system clipboard into Vim. The "+ register is Vim's connection to the operating system clipboard, allowing you to paste text copied from other applications like your browser, terminal, or text editor.

How it works

  • " tells Vim you are specifying a register
  • + is the system clipboard register (the OS clipboard)
  • p pastes the register contents after the cursor

Example

You copy the text Hello from Chrome in your web browser using Cmd+C (or Ctrl+C). Switch to Vim and press "+p in normal mode. The text Hello from Chrome is pasted at the cursor position.

The two clipboard registers

Vim has two clipboard-related registers:

  • "+ — the system clipboard (what you copy with Cmd+C / Ctrl+C in other apps)
  • "* — the primary selection (on Linux/X11, this is the text you highlight with the mouse; on macOS, "* and "+ behave the same)

Tips

  • Use "+y to yank (copy) text from Vim to the system clipboard
  • Use "+P (uppercase P) to paste the clipboard contents before the cursor
  • Use "+yy to copy the entire current line to the system clipboard
  • If you want y and p to always use the system clipboard, add this to your vimrc:
set clipboard=unnamedplus
  • To check if your Vim build supports the clipboard, run :echo has('clipboard') — it should return 1
  • If clipboard support is missing, install a Vim build with +clipboard (e.g., brew install vim on macOS or sudo apt install vim-gtk3 on Ubuntu)
  • In insert mode, use <C-r>+ to paste from the system clipboard without leaving insert mode

Next

How do I edit multiple lines at once using multiple cursors in Vim?