Copy all the lines to clipboard

Xinus picture Xinus · Oct 25, 2009 · Viewed 872.7k times · Source

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?

Answer

Rook picture Rook · Oct 25, 2009

Use:

:%y+

to yank all lines.

Explanation:

  • % to refer the next command to work on all the lines
  • y to yank those lines
  • + to copy to the system clipboard

NB: In Windows, + and * are equivalent see this answer.