Yank entire file

▼魔方 西西 提交于 2019-11-26 18:46:11

问题


I often write something in gVim, then need to copy-paste it into another application.

Is there an easy way to yank the entire file? I usually do something like this

ggVG"+y

(Go to top, visual-line mode, go to bottom, yank)

But is there a better way that I'm missing out on?


回答1:


I use the following instruction: :%y+




回答2:


ggyG (go to the first line, yank to the last line)

Edit: Ah, system clipboard. Doesn't exactly roll off the fingers, but: gg"+yG




回答3:


A working solution in old vi is :r filename in the new file.




回答4:


Another method is this:

ggyG

Go to the top, and yank to the bottom.




回答5:


ggyG

(Go to top, yank to bottom)




回答6:


I use the following instruction: :%y.




回答7:


:0,$ y

I dunno which way is easier.




回答8:


In OSX:

ggVG
!tee >(pbcopy)

Which I find nicer than:

ggVG
:w !pbcopy

Since it doesn't flash up a prompt: "Press ENTER or type command to continue"




回答9:


Or simply in your .vimrc:

nmap <silent> <F5> ggVG"+y

So you can just use one key :)




回答10:


:%y without + works over the entire system if you are using neo-vim (nvim).

This lets us avoid stretching our fingers to the + - acctually making this shortcut better than ggyG.




回答11:


It's dirty but you don't have to use the shift key at all and only 3 different keys which may be faster:

gg1111yy

(Assuming the file is shorter than 1111 lines)




回答12:


On Windows I often just do CTRL-A, CTRL-C to copy all to the windows clipboard... Can't get easier than that!

I'm using a standard gvim 7.1 from the website...

(BTW: also works on my mac with MacVim and that funny mac-key+A, mac-key+C)



来源:https://stackoverflow.com/questions/829935/yank-entire-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!