views:

1319

answers:

8

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, but is there a better way that I'm missing out on?

ggVG"+y

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

+7  A: 

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

Adam Backstrom
+3  A: 

Another method is this:

ggyG

Go to the top, and yank to the bottom.

gms8994
+3  A: 

ggyG

(Go to top, yank to bottom)

Francisco Canedo
+2  A: 

:0,$ y

I dunno which way is easier.

+2  A: 

Or simply in your .vimrc:

nmap <silent> <F5> ggVG"+y

So you can just use one key :)

dr Hannibal Lecter
A: 

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)

Daren Thomas
windows gvim adds some extra shortcuts that aren't in the other versions, to try and make it fit in better with windows users. ctrl+a, ctrl+c, are two examples of those.
davr
Mm, ctrl-c has quite a different meaning to a terminal user.
Xiong Chiamiov
sure, but when in windows, do as the windows do :) Just saying, gvim and MacVim honor the platforms standard clipboard shortcuts - there is nothing wrong with using them either....
Daren Thomas
+21  A: 

I use :%y+

Luc Hermitte
That's what I was looking for, I could never figure out how to do that. Thanks.
Chad Birch
+2  A: 

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

mouviciel