1

I like to use vim to edit other (non-programming languages) stuff. So I paste the content into vim and make the changes.

How can I copy all of the text back into the primary clipboard for pasting?

Note that I use iTerm2 and the ability to use * isn't there as it is with the basic osx terminal app.

I don't want to copy to a vim internal register (such as the y yank command), I want to copy to the system clipboard.

Also, I want the contents of the whole file, including the content which is off-screen?

The alt-left-click-drag with mouse doesn't work.

3

I'm sure this is a duplicate but:

gg"*yG

gg go to the first line
"*y start a yank to the system clipboard "register"
G move to the end of the file (you will see how many lines were yanked)

  • 3
    @MichaelDurrant talking in ALL CAPS doesn't make you right. The * and + buffers are for interfacing with the system clipboard. See vi.stackexchange.com/a/96/205 – muru Aug 9 '15 at 9:57
  • This simply didn't work for me. – Michael Durrant Aug 9 '15 at 18:13
  • 2
    @MichaelDurrant Hmm. OSX, isn't it? Try the + register (gg"+yG). – muru Aug 10 '15 at 13:44
  • Thanks muru, Looks like my version of bash doesn't this functionality. I am on Yosemite 10.10.4 – Michael Durrant Aug 10 '15 at 17:59
1

This alternative option using a : command worked for me:

:1,$!pbcopy

This is useful for referring to line numbers, etc without having to navigate and highlight the area.

0

I've solved this in a better way than my other answer:

First of all get the new vim with

brew install vim

and then do

vim --version

Make sure it is 7.4+ Note that if you do vi --version you may that vi is at 7.3

Now make vi use that newer vim

alias vi=vim

and add that alias to your .bash_aliases file (or wherever you put aliases)

Finally add

set clipboard=unnamed

to your .vimrc (not .bashrc!)

Start a new shell and it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.