Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 925
Adrien Avatar asked Jul 10 '12 15:07

Adrien


People also ask

How do I copy and paste from vim to clipboard?

We can use the “+p and <Ctrl+r>+ in normal and command mode, respectively. However, it might be more convenient if we use the <Ctrl+Shift+v> hotkey since it does the same thing as “+p. Similarly, <Ctrl+Shift+c> will yank the text into the + register to be available for pasting outside of Vim.

How do I select and copy text in Vim?

Copying in Vim Copying text in Vim is also referred to as yanking. Use the y key on the keyboard when performing this operation. There are a number of yank commands, mainly differing on the amount of text you want to copy. Once in normal mode, move the cursor to the needed place and use the appropriate command.


1 Answers

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.

like image 87
Conner Avatar answered Sep 19 '22 18:09

Conner