Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Using the vim text editor, I am looking for a method to copy content highlighted in visual mode to the system clipboard (i.e. I would then be able to Ctr-v that content say in a browser window).

Is there a standard way to copy content directly to the system clipboard? If not is there a suited hack to enable it for Mac OS 10.7.3?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

If your VIM was built with the clipboard feature enabled, then you select your text in visual mode, and then type "*y.

To paste from the clipboard, do "*p.

share|improve this answer
    
@Kurt The text register "* is special, it places the selected text into the X CLIPBOARD. –  Keith Apr 10 '12 at 12:12
    
This does not work for me. Each time I press "* I get a bell and then y/p perform their independently mapped actions. –  rudolph9 Apr 10 '12 at 17:40
    
This seems to be an issue with OS X, from what I have gather it does not properly map the X CLIPBOARD as mentioned by Keith. (it seems rather unsuited to even call OS X Unix anymore!) –  rudolph9 Apr 10 '12 at 17:49
1  
For OSX this article was rather helpful. Basically there is a command pbcopy and pbpast which you able to call for say the current line . !pbcopy or if you don't want the current line cut .w !pbcopy. –  rudolph9 Apr 10 '12 at 17:59
    
Right, the "* register is only available where VIM was built with the right settings. It might be that OS X can't do that, but I can't check as I don't have it. –  ams Apr 10 '12 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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