vim system register * and + not working

江枫思渺然 提交于 2019-12-23 07:28:07

问题


:echo has('clipboard') returns 1, but whenever I execute "+yy" or "*yy" nothing seems to be in those registers. If I use regular yy to copy another line of text, then try to paste from the register using CONTROL+V nothing happens. If I try "+p vim pastes the line of text I copied using the regular yy command.

What's going on here? I'm on FreeBSD by the way.


回答1:


Your vim version may not be compiled with X11 clipboard integration.

In vim run the :version command and look for xterm_clipboard in the output. It will be prefixed with a + (supported) or - (unsupported) sign.




回答2:


If you have copy something to clipboard and paste that in vim, you can use "+p.

+ is a quoteplus, which means CLIPBOARD documented X selection. :help quoteplus for more information.

If you want to copy something in vim to clipboard and paste the content in the other place by Ctrl+v, you can do "+yy, this will copy the current line to clipboard.

more information about vim register:

:help registers
:help quotestar



回答3:


Another thing that could be going on is your DISPLAY environment variable is not being set correctly. This could happen sometimes if you're running vim from tmux or screen.

Try opening a new terminal, running echo $DISPLAY, and then from the terminal running vim, leave vim, execute export DISPLAY=:0 (but replace :0 with the output from your other terminal), and then re-enter vim and see if clipboard works by doing "+p.

This solved my problem!



来源:https://stackoverflow.com/questions/18385084/vim-system-register-and-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!