1

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.

2 Answers 2

3

you have to yank it to the clipboard register

"*y

:help registers will tell you more about that.

2
  • 1
    In my case, "+y copies to the "Ctrl-V" accessible clipboard. Thanks for the hint!
    – Boldewyn
    Mar 12, 2010 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, 2010 at 11:33
2

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .