Yank all lines in a file

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Yank all lines in a file

Ben Klein
I have a silly question: What is the fastest way to yank all lines (V) in an opened file? I normally do:

1
G
V
G
yy

Is that the simplest way to do this?

--
b

smime.p7s (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

jk121960
gg
v
shift-g
 
Gerald Klein DBA
[hidden email]
www.geraldklein.com
geraldklein.wordpress.com
[hidden email]
708-599-0352

Arch/Gentoo Awesome, Ranger & Vim the coding triple threat.
Linux registered user #548580
 
From: Benjamin Klein
Sent: Friday, August 16, 2013 5:45 PM
To: [hidden email]
 
I have a silly question: What is the fastest way to yank all lines (V) in an opened file? I normally do:

1
G
V
G
yy

Is that the simplest way to do this?

--
b

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Tim Chase
In reply to this post by Ben Klein
On 2013-08-16 17:45, Benjamin Klein wrote:

> I have a silly question: What is the fastest way to yank all lines
> (V) in an opened file? I normally do:
>
> 1
> G
> V
> G
> yy
>
> Is that the simplest way to do this?

If you insist on visual mode, I think you mean "1GVGy" not
"1GVGyy".  A couple variants:

  ggVGy
  ggyVG
  1GyVG

Depending on my whim, I occasionally use that, but tend to reach for

  :%y

most frequently, which one character shorter and allows me to also
specify certain target registers in one character rather than two
(the lettered ones do require a space to separate them, but most
frequently I'm doing this to get it in the system clipboard)

  :%y+    " yank to the clipboard register

which is two extra characters with the method you suggest:

  gg"+yVG
  ggVG"+y
  1G"+yVG
  1GVG"+y

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Dominique Pellé
In reply to this post by Ben Klein
Benjamin Klein <[hidden email]> wrote:

> I have a silly question: What is the fastest way to yank all lines (V) in an opened file? I normally do:
>
> 1
> G
> V
> G
> yy
>
> Is that the simplest way to do this?


You have one y too much there.  Instead of 1G it's quicker to type gg.

But you can also yank everything with:

:%y<Enter>

(4 keystrokes)

Another solution in 4 keystrokes:

ggyG

Neither of them use visual mode.

Dominique

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Tim Chase
On 2013-08-17 01:03, Dominique Pellé wrote:
> Another solution in 4 keystrokes:
>
> ggyG

While this works, I tend to shirk it as I occasionally fly with
'nosol' set. It doesn't happen to impact it in this case, but the
extra thought exertion isn't worth it for me, so I just use the

  :%y<enter>

that you mention :-)

-tim



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Steve Litt
In reply to this post by Ben Klein
On Fri, 16 Aug 2013 17:45:48 -0500
Benjamin Klein <[hidden email]> wrote:

> I have a silly question: What is the fastest way to yank all lines
> (V) in an opened file? I normally do:
>
> 1
> G
> V
> G
> yy
>
> Is that the simplest way to do this?

I use ggyG

But I know someone's going to find something better.

Thanks,

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

David Ohlemacher
1GvGy does not get the end of the last line. G just takes you to the
first non-blank character of a line.

I would use 1GvG$y


--
David Ohlemacher
Principle Software Engineer
Scientific Solutions Inc.
99 Perimeter Rd Nashua New Hampshire 03063
603-880-3784

. o .
. . o
o o o

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

gthm159
In reply to this post by Tim Chase
On Saturday, August 17, 2013 1:21:13 AM UTC+2, Tim Chase wrote:

> On 2013-08-17 01:03, Dominique Pellé wrote:
>
> > Another solution in 4 keystrokes:
>
> >
>
> > ggyG
>
>
>
> While this works, I tend to shirk it as I occasionally fly with
>
> 'nosol' set. It doesn't happen to impact it in this case, but the
>
> extra thought exertion isn't worth it for me, so I just use the
>
>
>
>   :%y<enter>
>
>
>
> that you mention :-)
>
>
>
> -tim

Is there a significant difference between using "ggyG" as against ":%y<enter>"?

I always use the former.

- Gautam

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Tim Chase
On 2013-08-17 01:15, Gautam wrote:
> Is there a significant difference between using "ggyG" as against
> ":%y<enter>"?
>
> I always use the former.

In exactly this case?  Not really.

However, as mentioned in another email, often my reason for yanking
an entire document is to send it to the system clipboard.  In that
case, it's a one-character difference:

  gg"+yG

vs

  :%y+<enter>

It's something that I do often enough that I've just defaulted to
using the Ex command.  For registers named with letters, it's a
wash.

Also, I like to keep my Ex skills sharp. ;-)

-tim




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Christian Brabandt
Hi Tim!

On Sa, 17 Aug 2013, Tim Chase wrote:

>   :%y+<enter>
>
> It's something that I do often enough that I've just defaulted to
> using the Ex command.  For registers named with letters, it's a
> wash.
>
> Also, I like to keep my Ex skills sharp. ;-)

You aren't alone mate ;)

regards,
Christian

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Yank all lines in a file

Tony Mechelynck
In reply to this post by David Ohlemacher
On 08/17/13 06:47, David Ohlemacher wrote:
> 1GvGy does not get the end of the last line. G just takes you to the
> first non-blank character of a line.

With a capital V (i.e. shift-v) it does, because that makes the visual
mode linewise.

>
> I would use 1GvG$y
>
>
Like Christian, I use :%y (or :%y+ to yank into the clipboard).


Best regards,
Tony.
--
War is peace.  Freedom is slavery.  Ketchup is a vegetable.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.