How to copy a selection to the OS X clipboard

后端 未结 27 2159
野趣味
野趣味 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:00

    You can use MacVim when you're on a Mac to easily access the clipboard using the standard OS keys.

    It's also fully backward compatible with normal Vim, so I don't even have to have a separate .vimrc.

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

    Command-c works for me in both MacVim and in the terminal.

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

    on mac when anything else seems to work - select with mouse, right click choose copy. uff

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

    Shift cmd c – set copy mode Drag mouse, select text, cmd c to copy selected text Cmd v to paste

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

    I used:

    map <C-x> :!pbcopy<CR>
    vmap <C-c> :w !pbcopy<CR><CR>
    

    It worked really well.

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

    Use Homebrew's vim: brew install vim

    Mac (as of 10.10.3 Yosemite) comes pre-installed with a system vim that does not have the clipboard flag enabled.

    You can either compile vim for yourself and enable that flag, or simply use Homebrew's vim which is setup properly.

    To see this for yourself, check out the stock system vim with /usr/bin/vim --version

    You'll see something like:

    $ /usr/bin/vim --version
    
    VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Nov  5 2014 21:00:28)
    Compiled by root@apple.com
    Normal version without GUI.  Features included (+) or not (-):
    ... -clientserver -clipboard +cmdline_compl ...
    

    Note the -clipboard

    With homebrew's vim you instead get

    $ /usr/local/bin/vim --version
    
    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 10 2015 14:04:42)
    MacOS X (unix) version
    Included patches: 1-712
    Compiled by Homebrew
    Huge version without GUI.  Features included (+) or not (-):
    ... +clipboard ...
    

    Note the +clipboard

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