Copy all the lines to clipboard

2019-01-07 01:13发布

Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it's not using clipboard to store those lines.

So is it possible?

标签: vim editor vi
22条回答
孤傲高冷的网名
2楼-- · 2019-01-07 01:55

(in reply to @rshdev, and to avoid having to recompile vim with +xterm_clipboard per @nelstrom in comments on OP)

there's a program called xclip that works like putclip on Ubuntu 11:

:%!xclip -sel clip
u

it's not installed by default. to install, use:

sudo apt-get install xclip
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-07 01:57

I tried a few of the commands that people have mentioned above. None worked. Then I got hold of the simplest of them all.

Step 1: vi <filename>
Step 2: Right click on the title bar of the Putty window
Step 3: Select "Clear scrollback" (to avoid copying the rest of your SSH session)
Step 4: Right click again and select "Copy all to clipboard".

查看更多
放荡不羁爱自由
4楼-- · 2019-01-07 01:57

You can use "cat" command to open file and use mouse to copy

查看更多
来,给爷笑一个
5楼-- · 2019-01-07 01:58

Do copy the whole file inside the vim or its tabs

y G 

then move to a tab and paste by

p

and to cut the whole file use

d G
查看更多
登录 后发表回答