Ubuntu 16.04, yank vim buffer content to system clipboard

https://stackoverflow.com/questions/10101488/cut-to-the-system-clipboard-from-vim-on-ubuntu
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:
git clone 有时候需要翻墙

# Get the compile-dependencies of vim
sudo apt-get -y build-dep vim
# Install python dev
sudo apt-get -y install python-dev
# Install xorg dev
sudo apt-get -y install xorg-dev
# Install git
sudo apt-get -y install git
# Get the source
git clone https://github.com/vim/vim.git vim_source
# Remove ./configure cache in case we have to run this twice due to permissions
# related issues.
rm vim_source/src/auto/config.cache
# Compile it
cd vim_source
make clean
./configure \
    --enable-perlinterp=dynamic \
    --enable-pythoninterp=dynamic \
    --enable-rubyinterp=dynamic \
    --enable-cscope \
    --enable-gui=auto \
    --enable-gtk2-check \
    --enable-gnome-check \
    --with-features=normal \
    --with-x \
    --with-compiledby="DevNull <darkstar@/dev/null>" \
    --with-python-config-dir=/usr/lib/python2.7/config-$(uname -m)-linux-gnu
# Build quickly (8 parallel jobs, hope your system doesn't get overwhelmed)
make -j8
# Need root to install
sudo make install

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.
You’ll end up with two vim’s: /usr/bin/vim and /usr/local/bin/vim. You can always run the old one with the explicit path. I’m not sure what you think is likely to be broken though: you can compile in any features that you need, but this configure script puts most stuff in. See ./configure –help for more options.
I should clarify my comment: you’ll also end up with two gvims: /usr/bin/gvim (from vim-gtk) and /usr/local/bin/gvim (a symlink to /usr/local/bin/vim that will open in GUI mode by default rather than the one names ‘vim’ that will open in console mode). It will support clipboards whether or not you’re in GUI mode (and even do so over ssh if you ssh -X with an X-server on the ssh client machine).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值