在 Ubuntu 上从 Vim 剪切到系统剪贴板 [英] Cut to the system clipboard from Vim on Ubuntu

查看:30
本文介绍了在 Ubuntu 上从 Vim 剪切到系统剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是随附的 Ubuntu 12.04 Beta 和 Vim.我正在尝试使用 Vim 将文本文件的内容复制到 Chrome 浏览器.我尝试过 +* y 及其所有变体.我试过 :set clipboard=unnamed:set clipboard=unnamedplus.不工作.我不是要尝试使用 xclip、GVim 或任何其他工具.我尝试过 xclip(不是 Ubuntu 12.04 中的标准包),但这也不起作用,也太费力了.

I am using Ubuntu 12.04 Beta and Vim that has come with it. I am trying to use Vim to copy the content of a text file to Chrome browser. I have tried +, * y and all its variants. I have tried to :set clipboard=unnamed and :set clipboard=unnamedplus. Not working. I am not trying to use xclip, or GVim or any of that. I tried with xclip (not a standard package in Ubuntu 12.04), but that too does not work, also too much effort.

如何将文本复制到剪贴板,然后粘贴到任何地方,例如 Chrome?

How do I copy the text to the clipboard and then paste anywhere, like Chrome?

推荐答案

您的 Vim 版本不支持 X,这是访问剪贴板所必需的.默认情况下,Ubuntu 提供了多个 vim 版本,并且只有 GUI 变体支持剪贴板访问.我总是从源代码重新编译 vim,以便单个 vim(带有 gvim 等的符号链接)支持所需的一切(包括从命令行切换到 GUI 版本的 :gui).这真的很容易做到:

Your version of Vim doesn't support X, which is required for clipboard access. By default, Ubuntu ships several builds of vim and only the GUI variant supports clipboard access. I always recompile vim from source so that a single vim (with symlinks for gvim etc) supports everything required (including :gui to switch from command line to GUI version). It's really very easy to do:

# Get the compile-dependencies of vim
sudo apt-get build-dep vim
# If you haven't got mercurial, get it
sudo apt-get install mercurial
# Get the source
hg clone https://vim.googlecode.com/hg/ vim_source
# Compile it
cd vim_source
./configure 
    --enable-perlinterp=dynamic 
    --enable-pythoninterp=dynamic 
    --enable-rubyinterp=dynamic 
    --enable-cscope 
    --enable-gui=auto 
    --enable-gtk2-check 
    --enable-gnome-check 
    --with-features=huge 
    --with-x 
    --with-compiledby="Your Name <youremail@domain.com>" 
    --with-python-config-dir=/usr/lib/python2.7/config
make && sudo make install

这会将其安装在 /usr/local 中,因此请确保它位于您的 PATH before /usr 中> 它将代替 Ubuntu 版本使用.

That will install it in /usr/local, so make sure that's in your PATH before /usr and it will be used instead of the Ubuntu versions.

这篇关于在 Ubuntu 上从 Vim 剪切到系统剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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