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

查看:302
本文介绍了在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 之前 /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天全站免登陆