Vim复制粘贴到系统缓冲区的行为异常 [英] Vim copy-paste to system buffer not behaving as expected

查看:187
本文介绍了Vim复制粘贴到系统缓冲区的行为异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很头疼,想弄清楚为什么vim没有复制到系统缓冲区。



这是我的工作流程:

  vim asd 
y1y
:q
vim qwe
p

在计算机A和计算机B上,这按我的意愿进行:从文件asd中拉出的行被放入文件qwe中。



在computerC上,这不起作用。



所有系统都在运行Ubuntu 8.04。 computerA已安装了vim-full软件包,computerB和computerC已安装了vim软件包。 computerA已安装xorg,正在使用fluxbox窗口管理器,并且可以在本地访问。 computerB和computerC没有X,并且我都把它们都塞进去。



我做了很多阅读,认为这是因为computerC是编译的使用-clipboard,但是我在所有三台计算机上都运行了vim --version,并且只有computerA是使用+ clipboard编译的。我相信用户的.vimrc文件和全局vimrc文件是相同的。如果有帮助,我可以发布vim --version的输出和vimrc文件的内容。

解决方案

默认情况下,Vim不起作用复制到系统缓冲区。记住内容的唯一方法是,如果vim的多个实例使用相同的.viminfo文件。

$ b可能由于文件权限或'viminfo'(该选项)中的其他设置而未写入.viminfo文件。



有关viminfo配置的更多信息,请参见

 :help'viminfo'

要查看每台计算机上的当前配置,请执行以下操作:

 :设置viminfo吗? 

另外,如果要使用系统剪贴板(必须存在,因此, d需要执行 ssh -X ),则可以使用:

  :set剪贴板+ =未命名

然后所有复制和粘贴操作将使用X11选择缓冲区。当然,您需要使用 + clipboard 编译的vim才能正常工作,因此它无法解决您的直接问题。请参阅:

 :帮助剪贴板 

了解更多信息。



也许您可以在每台计算机上发布以下结果?

 :set viminfo? 
:设置剪贴板?

这将有助于我们更详细地诊断问题。您还可以尝试:

  vim asd 
ayy
:q
vim qwe
ap

这将使用寄存器 a 而不是未命名的寄存器。


I'm having a headache trying to figure out why vim isn't copying to a system buffer.

Here's my workflow:

vim asd
y1y
:q
vim qwe
p

On computerA and computerB, this works as I want it to: the line yanked from the file asd is put into the file qwe.

On computerC, this doesn't work.

All systems are running Ubuntu 8.04. computerA has the vim-full package installed, computerB and computerC have the vim package installed. computerA has xorg installed, is using the fluxbox window manager, and is accessed locally. computerB and computerC don't have X, and I'm sshing into both of them.

I've done a lot of reading and thought it was because computerC was compiled with -clipboard, but I ran vim --version on all three computers and only computerA was compiled with +clipboard.

Am I missing something obvious? I believe the user's .vimrc and the global vimrc files are the same. I can post output of vim --version and contents of vimrc files if that would help.

解决方案

Vim by default doesn't copy to a system buffer. The only way that it would remember the contents is if the multiple instances of vim use the same .viminfo file. It's possible that the .viminfo file isn't being written due to file permissions or due to a different setting in 'viminfo' (the option).

For more information on the viminfo configuration, see

:help 'viminfo'

To look at your current configuration on each computer, do:

:set viminfo?

As an aside, if you want to use the system clipboard (which must be present, so you'd need to do ssh -X), you can use:

:set clipboard+=unnamed

Then all copy and paste operations will use the X11 selection buffer. Of course, you need vim compiled with +clipboard for this to work, so it won't solve your immediate problem. See:

:help 'clipboard'

for more information.

Perhaps you could post the result of the following on each computer?

:set viminfo?
:set clipboard?

This would help us to diagnose the problem in more detail. Could you also try:

vim asd
"ayy
:q
vim qwe
"ap

This will use register a instead of the unnamed register.

这篇关于Vim复制粘贴到系统缓冲区的行为异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆