简体   繁体   中英

How do I paste to console Vim from the system clipboard?

I can copy text from Vim to other Mac applications with "*y . But when I try to paste into Vim, from TextEdit for example, I cannot paste text with "*p . Is there some setting that I missed?

"*p and "*y don't work in the default Vim shipped with OS X simply because it was not compiled with clipboard support.

You may be led to believe that they work, somehow, because Vim won't complain if you use a non-existing register and yank in or put from the default register instead. :reg + and :reg * should show no content at all.

It's easy to verify if your Vim comes with clipboard support. The following command

$ /path/to/vim --version | grep clipboard

should find -clipboard and -xterm-clipboard which mean "no clipboard support".

The only practical way to have clipboard support is to install a proper Vim build, either by downloading MacVim, by using a package manager like Homebrew or Macports or by compiling it manually. I'd suggest the first option: it's the least geeky but the simplest and fastest.

No need to install MacVim, just put this line in your .vimrc file:

set clipboard=unnamed

Edit: It seems the default version that ships with Mac OS (Mountain Lion) doesn't come compiled with clipboard support. Since this is the case I would recommend just using Command+V to paste from the system clipboard or installing a new version of vim through macports .

Use "+p instead.

I believe + is register that refers to the system clipboard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM