Add the following lines to vimrc to copy and paste between multiple terminals. (Mac only) vmap y :w !pbcopy<CR><CR> nmap yy :.w !pbcopy<CR><CR> nmap p :r !pbpaste<CR><CR>
【Explanation】
This is mainly due to a set of useful operating system clipboard commands under mac:
pbcopy, pbpaste .
For example, you can use it like this:
cat foo.txt | pbcopy #Copy the content of foo.txt to the system clipboard
pbpaste > bar.txt #Write the contents of the system clipboard to bar.txt
and then vim's w! and r! (note the space in the middle) can be responsible for writing a certain piece of text
or reading it from a certain command, a bit like a linux pipeline Function.
Here, the default y and p functions of vim are changed, so that y is directly copied to the system clipboard, and
p is directly pasted from the system clipboard; therefore, clipboard sharing between multiple terminals is realized. And because the system clipboard is operated, the clipboard sharing between the terminal's vim and other applications is
also realized .
Reprinted from: http://www.douban.com/note/202175976/