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
you can press gg to locate your curser to the start of the file,then press yG to copy all the content from the start to end(G located) to buffer.good luck!
:%y a
Yanks all the content into vim's buffer,
Pressing p
in command mode will paste the yanked content after the line that your cursor is currently standing at.
I couldn't copy files using the answers above but I have putty and I found a workaround on Quora.
Note: it copies all the printed characters of that session to the log file, so it will get big eventually. In that case, delete the log file and cat the target file so you get that particular file's content copied on your machine.
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 fileon Mac
copy selected part: visually select text(type v
or V
in normal
mode) and type :w !pbcopy
copy the whole file :%w !pbcopy
past from the clipboard :r !pbpaste
If you're using Vim in visual mode, the standard cut and paste keys also apply, at least with Windows.
Under Ubuntu terminal (Gnome) at least, the standard copy also works (CTRLSHIFTC, although there doesn't appear to be a standard keyboard shortcut for select all
(other than ALTE followed by A).