VI Editor : Yank the entire file to clipboard (specific to OS X)

前端 未结 3 1695
忘了有多久
忘了有多久 2020-12-31 05:40

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 prev

3条回答
  •  既然无缘
    2020-12-31 06:05

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

    You have three options:

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

      $ cat filename | pbcopy
      
    2. use pbcopy from Vim

      :%w !pbcopy
      
    3. get your own Vim with clipboard support

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

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

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

提交回复
热议问题