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.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
Boldewyn
  • 4,468

2 Answers2

4

you have to yank it to the clipboard register

"*y

:help registers will tell you more about that.

akira
  • 63,447
3

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)

suspectus
  • 5,008
Acorn
  • 51