I am using gVim on Ubuntu 10.10. I want to copy (yank) text to the system clipboard, so that the copied text is available in other applications.
This works with "+y
. But I want to have it working with y
.
I have tried to map y
to "+y
but then yy
doesn't work anymore (since it produces "+y"+y
).
I have also tried :set clipboard=unnamed
but this works only the other direction: Text in the system clipboard I can paste with p
.
Press v to select characters, or uppercase V to select whole lines, or Ctrl-v to select rectangular blocks (use Ctrl-q if Ctrl-v is mapped to paste). Move the cursor to the end of what you want to cut. Press d to cut (or y to copy). Move to where you would like to paste.
In vim command mode press v , this will switch you to VISUAL mode. Move the cursor around to select the text or lines you need to copy. Press y , this will copy the selected text to clipboard.
You need to make sure clipboard is activated (which is probably not the case). if you get "-clipboard" then you would have to install vim again with the "clipboard" functionality. You can do it it by installing "vim-gtk3" or "gvim".
In this mode, you can run Vim commands and navigate through the file. To go back to normal mode from any other mode, just press the Esc key. Vim has its own terminology for copying, cutting, and pasting. Copy is called yank ( y ), cut is called delete ( d ), and paste is called put ( p ).
Did you try to map with this command:
noremap y "+y
? This mapping contains a serious mistake: it maps y
in normal, visual and operator-pending modes, while you need only normal and visual modes. Use the following:
nnoremap y "+y vnoremap y "+y
Also try set clipboard=unnamedplus
(it requires at least vim-7.3.74). set clipboard=unnamed
works in both directions, but it sets «mouse» (*
) register which is different from clipboard register (+
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With