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?
To copy to clipboard, do " + y and [movement]. So, g g " + y G will copy the whole file.
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.
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.
- 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.
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.
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.
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.
Use:
:%y+
to yank all lines.
Explanation:
%
to refer the next command to work on all the linesy
to yank those lines+
to copy to the system clipboardNB: In Windows, +
and *
are equivalent see this answer.
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 fileIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With