How to copy a selection to the OS X clipboard

后端 未结 27 2157
野趣味
野趣味 2020-11-29 14:17

I have an area selected in Vim. How can I copy it into the OS X clipboard?

(The OS X clipboard can be written to via a pipe to /usr/bin/pbcopy)

相关标签:
27条回答
  • 2020-11-29 15:22

    double-quote asterisk ("*) before any yank command will yank the results into the copy buffer. That works for Windows and Linux too.

    0 讨论(0)
  • 2020-11-29 15:22

    Visually select the text and type:

    ggVG
    !tee >(pbcopy)
    

    Which I find nicer than:

    ggVG
    :w !pbcopy
    

    Since it doesn't flash up a prompt: "Press ENTER or type command to continue"

    0 讨论(0)
  • 2020-11-29 15:22

    If you are using MacPorts you can upgrade your VIM to include clipboard support via:

    port install vim +x +x11
    

    Now you use the "+ register to yank your text directly to your Mac clipboard. Works like a charm.

    0 讨论(0)
提交回复
热议问题