Vim can actually access the system clipboard (and, on Linux, the X clipboard). It's accessed as the * register (or + for the X clipboard). So, for instance:
"*dd
"*p
or
"+yy
"+P
And so on. Very convenient (and also much faster than Ctrl+V). On Ubuntu, this is only available in the Vim provided by vim-gnome or vim-gtk (even when running in a terminal).
It's only available when Vim is compiled with +xclipboard support. I actually found that on an older version of CentOS (v4, I don't know if it's different in newer versions), the 'vim' command and the 'gvim' command were separately compiled binaries so that 'vim' command didn't share the +xclipboard support. On Debian/Ubuntu, I believe they are the same binary.
Exactly. On my machine (Ubuntu 11.04) the binary (/usr/bin/vim.basic) provided by the vim package is compiled with -clipboard -xterm_clipboard, and the binary (/usr/bin/vim.gnome) provided by vim-gnome is compiled with +clipboard +xterm_clipboard.
I'm sorry for the confusion. There are two ways it can be faster. The way you understood it, I guess, is in typing. The difference here is:
i Ctrl v Esc
vs
(Shift) " * p
Where, on my keyboard, both " and * requires the shift key, but YMMV.
What I meant, though, is the actual input of text. When pasting with Ctrl+V, that's like one character at a time for Vim, and that's visible, so if you paste a large body of text you can actually see it scrolling past. When working with buffer commands, it works just any other internal Vim buffer operation, which is instantaneous.
Its not. You usually do most of your copying and pasting within vim so you can just use the normal past command, but it is annoying when you want to do something with the system clipboard.
When the author says "command line Vim" he means "Vim running in a terminal emulator".
And pasting to terminal Vim doesn't suck if your Vim is configured to detect mouse clicks or interface with the system clipboard. Using the system paste shortcut (command- or ctrl-V) in insert mode is not the way to do it.
Unless, of course, the system clipboard is on a different machine than the running copy of Vim. This is useful advice, you really don't have to be so negative about it just because you aren't in a situation where it's applicable.
If your ssh session has X11 forwarding enabled, and the remote terminal Vim has +xclipboard support, then you can use the "+P keystroke to paste directly from the clipboard into Vim.
Good point on my wording, thank you. I will change that to make it less confusing. As for middle-click, I really don't want to use the mouse. I don't use it for pasting anywhere else, so why would I change that for Vim?
As mentioned elsewhere, if your vim is compiled with clipboard support(:version and look for +clipboard), you can copy/paste from the clipboard.
* is the Linux selection register.
+ is your clipboard.
So yanking is just set paste, "+y or " * y, set nopaste. Similarly you can do a "+d in vim and ctrl-v it in your browser or anywhere you can access the clipboard. You can " * d/" * y and paste it with your middle mouse button.
perhaps, I'm forgetting something, but these solutions seem overly complicated.
I just have this in my .vimrc, and pasting (with formatting), is as simple as copying text, going to vim and hitting 'p' in command mode.
for middle-click (system) clipboard:
:set clipboard=unnamed
for ctrl-c (X11) clipboard:
:set clipboard=unnamedplus
couple caveats:
* +xterm_clipboard
* 'unnamedplus' is only for >= 7.3.74
<ESC>
(normal mode)
q:
(fully vim editable window of :command line history)
(edit one of the command lines, yank and put all you like)
(or edit the new blank command line at the bottom)
<ESC><ENTER>
(to execute the current line, or)
:q
(to quit without executing)
(normal mode)
Notice the symmetry of q: to get in, and :q to get out (if you don't execute).