VI编辑器:将整个文件发送到剪贴板(特定于OS X) [英] VI Editor : Yank the entire file to clipboard (specific to OS X)

查看:105
本文介绍了VI编辑器:将整个文件发送到剪贴板(特定于OS X)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在VI编辑器中将所有行从文件复制到剪贴板.我从SO的先前文章中尝试过*yG+yG"+yG:%y+,但是在OS X中没有任何作用.

Is there any way to copy all lines from a file to clipboard in VI editor. I have tried *yG, +yG, "+yG and :%y+ from previous posts in SO, but nothing works in OS X.

推荐答案

Mac OS X随附的默认Vim /usr/bin/vi[m]未与剪贴板支持一起编译.

The default Vim shipped with Mac OS X, /usr/bin/vi[m], isn't compiled with clipboard support.

您有三个选择:

  1. 从命令行使用pbcopy,而不使用Vim

  1. use pbcopy from the command line, without using Vim

$ cat filename | pbcopy

  • 使用Vim中的pbcopy

  • use pbcopy from Vim

    :%w !pbcopy
    

  • 使用剪贴板支持获取自己的Vim

    您可以通过 MacPorts 通过下载 MacVim 或通过构建

    You can do that through MacPorts or Homebrew, by downloading MacVim or by building from the source.

    使用y使用特定寄存器的正确方法是"{register}y.

    Also the correct way to use a specific register with y is "{register}y.

    请参见终端中的$ man pbcopy以及Vim中的:help clipboard:help !.

    See $ man pbcopy in your terminal and :help clipboard and :help ! in Vim.

    这篇关于VI编辑器:将整个文件发送到剪贴板(特定于OS X)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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