Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Having a chunk of text selected in Vim's visual mode, I'd like to copy that to the system's clipboard (be it the primary or X11's). Is there an easy solution for this? Obviously, a simple y doesn't do the trick.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

you have to yank it to the clipboard register

"*y

:help registers will tell you more about that.

share|improve this answer
    
In my case, "+y copies to the "Ctrl-V" accessible clipboard. Thanks for the hint! –  Boldewyn Mar 12 '10 at 11:22
    
well, keep the 2 buffers in sync with nongnu.org/autocutsel ... in the help of vim the diffs between the 2 clipboard mechanisms is explained as well. but since you are happy already ... :) –  akira Mar 12 '10 at 11:33

The visual selection (v, V, or CTRL-V) can automatically be copied to the X11 selection (* buffer).

In non-gui mode the clipboard option controls this (only supported if +xterm_clipboard appears when you type vim --version). In gui mode guioptions controls it.

This makes all Visual mode selections automatically go to the X11 primary selection:

    set clipboard+=autoselect
    set guioptions+=a

This turns it off:

    set clipboard-=autoselect
    set guioptions-=a

See help 'clipboard' (single quotes required)

share|improve this answer

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.