问题
So I'm a real noob to VIM and trying now again to get finally to the level of productivity.
One big problem I have with this editor is, that it uses a clipboard for itself, which I don't understand why.
With VIM I have now 3 clipboards on my system, which is totally unnecessary from my point of view. The global clipboard with CTRL+x, CTRL+c and CTRL+v, the clipboard on mousebutton3 which pastes the last highlighted text and now the VIM clipboard I can use with y and p in VIM.
There are some threads about this topic, but the answers only confuse me more. So how do I accomplish, that VIM only uses the global clipboard and the clipboard on mousebutton3?
Some may say that I should use *, but that only goes through the lines and then outputs "search hit BOTTOM, continuing at TOP" at the bottom. Maybe I don't understand the syntax and the answers suggest me to use a different keystroke before hitting *, but I have no clue about what I could be doing wrong.
回答1:
Maybe I don't understand…
Yes. That seems to be your problem.
Assuming you have a proper Vim installed and :echo has('clipboard')
returns 1
, you have direct access to your system's two "clipboards" via their associated registers:
- PRIMARY (middle mouse button), via
"*
, - CLIPBOARD (Ctrl+c, Ctrl+x, Ctrl+v), via
"+
.
You are supposed to press "
, followed by *
or +
, followed by y
or p
.
If you want to yank something in Vim and paste it in another program with a click on your middle mouse button, use the *
register:
"*yy
If you selected something in another program and want to put it in Vim, use the *
register:
"*p
If you want to yank something in Vim and paste it in another program with Ctrl+v, use the +
register:
"+yy
If you copied something in another program with Ctrl+c and want to put it in Vim, use the +
register:
"+p
You can synchronize "*
and ""
(the register used by y
and p
by default) with this line in your vimrc
:
set clipboard^=unnamed
If you want to synchronize "+
and ""
:
set clipboard^=unnamedplus
If you want to synchronize both:
set clipboard^=unnamed,unnamedplus
This should allow you to yank/put between programs without having to tell Vim what register to use.
Reference:
:help registers
:help x11-selection
:help 'clipboard'
来源:https://stackoverflow.com/questions/41086958/vim-use-system-clipboard