Reputation: 1789
I intend to copy something from 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!
Upvotes: 7
Views: 10660
Reputation: 2362
Select line[s] by using V
command then execute this selection by command :'<,'>w !sh
Upvotes: 2
Reputation: 7990
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.
Upvotes: 5
Reputation: 2439
" + y to yank text in vim, then ctrl + shift + v to paste in the terminal.
Upvotes: 3
Reputation: 195089
from the comments, it seems that your mouse middle button works for *
buffer, you can select text in vim, then press: 3 keystrokes:
"*y
and switch to other program, terminal, browser or whatever, click mouse middle to get yanked text.
read :h y
for details, how to yank text and save in a specific register (in this case, it is register *
)
Upvotes: 2