Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy all the lines to clipboard

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?

like image 698
Xinus Avatar asked Oct 25 '09 04:10

Xinus


People also ask

How do I copy all lines in a file?

To copy to clipboard, do " + y and [movement]. So, g g " + y G will copy the whole file.

How do you copy all lines in vi?

You can use a movement command or up, down, right, and left arrow keys. Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.

How do you copy everything in less?

Bookmark this question. Show activity on this post. In Less (Linux terminal), I can select lines with the mouse and then use Ctrl+Shift+C to copy to the clipboard.

How to copy and paste text lines to clipboard?

- LEFT CLICK into a word of the LAST TEXT LINE. all selected lines should appear in yellow now. - RELEASE the CONTROL KEY. - the selected lines are now in your clipboard. instant copy a single line to clipboard Hold CONTROL+SHIFT pressed, then left-click into a line to copy the whole line instantly to the clipboard.

What happens to the copied lines in the clipboard?

The copied lines are removed from the clipboard. The PASTE command determines the character set of the data in the clipboard. If this is different to the character set being used for the file being edited an automatic conversion occurs for the data being pasted into the file. If ASIS is specified, then the automatic conversion does not take place.

How do I copy a file to the clipboard?

The clipboard is buffer +. To copy to clipboard, do "+y and [movement]. So, gg"+yG will copy the whole file. Just to add to this (4 years later...), this has a slight drawback in that your cursor position will jump to the top of the file.

How to keep multiple copied items in clipboard in Windows 10?

However, copying multiple items can be a painful task. Have you ever frustrated after copying text or image to clipboard and realized that the previously copied content was lost? Well, the latest version of Windows 10 has an answer to your problem. You can enable clipboard history and keep multiple copied content in the clipboard.


2 Answers

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.

like image 176
Rook Avatar answered Oct 25 '22 02:10

Rook


You should yank the text to the * or + registers:

gg"*yG

Explanation:

  • gg to get the cursor to the first character of the file
  • "*y to start a yank command to the register * from the first line, until...
  • G to go the end of the file
like image 35
Christian C. Salvadó Avatar answered Oct 25 '22 00:10

Christian C. Salvadó