vimcopyputtypaste

How to copy some text from within Vim to shell command line?


I intend to copy some text from within Vim editor to shell command line. I have tried many ways, but I find all of them only work when in the same Vim editor. My need is to copy and paste between Vim editor and shell command line. That's, Vim -> shell

PS: I am using Putty.

EDIT:

BTW, what if just copy something from Vim editor and paste it to terminal both in a Unix/Linux box?

ATTENTION:

Output of :echo has("X11") in vim is 0, so my system does not support X11!


Solution

  • If your vim version >= 7.3.74, you can set the vim to use the system clipboard by default by adding a line to your .vimrc:

    set clipboard=unnamedplus
    

    for the detail, see this link. Then you use the y(ank) command in vim, the content is in the system clipboard.

    EDIT:
    this solution and the "*y solution require the Vim that has clipboard support. Since you're lack of that, use cat/grep/less/tail... to extract the text you want to copy.