Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a selection to the OS X clipboard

People also ask

How do you copy multiple items to the clipboard on a Mac?

Or, click at the beginning of a paragraph and press Control + K , and your Mac will cut the entire paragraph. To paste, use your default Command + V shortcut to paste the first item. Then, press Control + Y to yank your second clipboard item back from the dead and paste it into your document.

How do I access clipboard on Mac OS X?

When in Finder, click on the Edit dropdown menu and then select Show Clipboard. A window will pop up showing you the last thing put in the clipboard. It will only do this with the main clipboard and the Universal Clipboard, not the secondary clipboard we talked about in the last section.

How do you set up clipboard on Mac?

Universal Clipboard requirements On your Mac: Choose Apple () menu > System Preferences, then click General. Go to the bottom of the window and select “Allow Handoff between this Mac and your iCloud devices.” On your iPhone, iPad, and iPod touch: Go to Settings > General > Handoff, then turn on Handoff.


For MacVim and Windows Gvim, simply add the following to your ~/.vimrc:

set clipboard=unnamed

Now all operations such as yy, D, and P work with the clipboard. No need to prefix them with "* or "+.


If the clipboard is enabled, you can copy a selected region to the clipboard by hitting "*y

To see if it is enabled, run vim --version and look for +clipboard or -clipboard. For example, it's not enabled by default on my 10.5.6 box:

% which vim
/usr/bin/vim
% vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Nov 11 2008 17:20:43)
Included patches: 1-22
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
...
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
...

If it had been compiled with +clipboard, I'd be able to use the "* register to access the system clipboard.

I downloaded the 7.2 source and compiled it (easy as tar xjf vim-7.2.tar.bz && cd vim72 && ./configure && make && sudo make install), and the clipboard was enabled:

% which vim
/usr/local/bin/vim
% vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 24 2009 17:31:52)
Compiled by [email protected]
Normal version with GTK2 GUI.  Features included (+) or not (-):
...
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
...

However, even after compiling, I couldn't copy to the clipboard when running vim in Terminal.app, only in X11.app.


You can visually select text and type :w !pbcopy<CR>

Or you can include the below key mappings in your ~/.vimrc file. They cut/copy text in visual mode to the operating system's clipboard.

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

source: http://drydevelopment.com/blog/vim-pbcopy-on-os-x


Depending on which version of Vim I use, I'm able to use the + register to access the clipboard.

"Mac OS X clipboard sharing" may have some ideas that work for you as well.


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