Ubuntu 11.04 上的 Vim:使用 Unity 剪贴板
问题是,使用 X11 剪贴板的旧方法(通过“加号”寄存器)在 Unity 中不起作用。有人遇到过这个问题吗?又是如何解决的呢?
The problem is, the old-way method to work with X11 clipboard (through "plus" register) doesn't work in Unity. Has anyone met the problem? And how it was solved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
安装 GVim 后问题自行解决。然后“plus”寄存器就可以正常工作了。
The problem solves itself after GVim installation. Then "plus" register works as it should be.
即使您没有安装
gvim
或启用xterm_clipboard
,您也可以使用xsel
来管理您的剪贴板(通过apt- 安装它)获取
)。我希望我的脚本对您有所帮助: https ://github.com/FUT/config-files/blob/master/vim-dotfiles/vim/settings/clipboard.vim
Even if you do not have
gvim
installed orxterm_clipboard
enabled, you may usexsel
to manage your clipboard (install it viaapt-get
).I hope my script will help you: https://github.com/FUT/config-files/blob/master/vim-dotfiles/vim/settings/clipboard.vim
使用:
sudo apt-get install vim-gtk
这将安装带有剪贴板支持的 vim。
像以前一样运行:
vim
Use :
sudo apt-get install vim-gtk
This will install vim with clipboard support.
Run as before:
vim
我不知道unity桌面,但我知道它是基于gnome库的。因此,如果您可以使用 dbus 与 unity 剪贴板交互,您可以考虑编写一个使用 dbus 来设置剪贴板内容的 shell 脚本。如果您将映射分配给过滤器命令,则该脚本可以依次接收来自 vim 的输入。当然,如果您知道任何其他可以设置剪贴板内容的命令行实用程序,则其工作原理类似。
我曾经在 .vimrc 中为旧的 dcop 和 klipper(KDE 剪贴板)提供了以下映射,您可以自定义它们:
:vmap k :w! $HOME/.vimclip:静默执行 "!dcop klipper klipper setClipboardContents \"$(cat $HOME/.vimclip)\" &>/dev/null &":重画!< CR>:r $HOME/.vimclip:redraw!
:nmap z :silent 执行 "!dcop klipper klipper getClipboardContents > $HOME/.vimclip"
例如要复制按 k在视觉模式下进行选择后。请注意,它按行复制和过去。
I don't know the unity desktop but I know that it is based on gnome libraries. So if you can use dbus to interact with unitys clipboard, you may consider writing a shell script which uses dbus to set the clipboard content. This script can in turn receive its input from vim if you assign a map to a filter command. Of course this works similarly if you know any other commandline utility which can set the clipboard content.
I used to have the following maps in .vimrc for the old dcop and klipper (the KDE clipboard) which you might customize:
:vmap k :w! $HOME/.vimclip<CR>:silent execute "!dcop klipper klipper setClipboardContents \"$(cat $HOME/.vimclip)\" &>/dev/null &"<CR>:redraw!<CR>
:nmap z :silent execute "!dcop klipper klipper getClipboardContents > $HOME/.vimclip"<CR>:r $HOME/.vimclip<CR>:redraw!<CR>
E.g. to copy press k after making a selection in visual mode. Note, that it copies and pasts line wise.
一段时间后我再次遇到这个问题。必须说我在 GNOME 终端中使用 vim,而不是也安装的 GVim。
有趣的是,加号寄存器在我的不同计算机上几乎同时停止工作。
首先我认为这是一个错误,因为图形版本是像以前一样安装的。但最后我只是启动了 GVim 并在那里测试了 plus 寄存器。它正在工作。之后,寄存器也开始在终端中工作。
因此,如果您再次遇到问题,当您已经安装了 GVim 时,只需启动它即可。这应该有帮助。
I have faced the problem again after while. Must say I use vim in GNOME Terminal, not GVim that is also installed.
What is interesting the plus register stopped working approximately at the same time on different computers of mine.
First I though it was a bug because the graphical version was installed as before. But at the end I just started GVim and tested the plus register there. It was working. After that the register began working in the terminal too.
So if you meet the problem again, when you have already installed GVim, just start it. This should help.