How to map yank to OS's clipboard in Vim? [dup

2019-05-06 05:16发布

问题:

Possible Duplicate:
vim: copy selection to OS X clipboard

While I succeeded to map paste from clipboard (nmap <leader>p "*p), the same for yank (nmap <leader>y "*y) doesn't seem working. Actually, it yanks in Vim's clipboard.

Any idea how to do it properly? I know of clipboard=unnamed but I might keep the old yank/paste vim's commands.

EDIT: It seems there is some confusion about my needs.

The command "*y works. So there is nothing wrong with the +clipboard thing in my Vim env. What does not work is the mapping stuff.

I want to add stuff like:

nmap <leader>y "*y # Doesn't work as expected. It copies only in Vim's clipboard, ie I have to type `p` to paste the copied content instead of `"*p`.
nmap <leader>p "*p # Works as expected.

Am I clearer?

2nd EDIT: Just in case, 'cause I have no idea what could help you helping me, there is the render of vim --version in my machine: https://gist.github.com/3090385

回答1:

If you're visually selecting before yanking then you need vmap not nmap. Otherwise, yank is a normal command and is expecting a motion command.