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?
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?
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 Ubuntu 12
you might try to install the
vim-gnome
package:I tried it, because
vim --version
told me that it would have the flag xterm_clipboard disabled (indicated by - ), which is needed in order to use the clipboard functionality.-> installing the vim-gnome package on Ubuntu 12 also installed a console based version of vim, that has this option enabled (indicated by a + before the xterm_clipboard flag)
On Arch Linux
you may install
vim-clipboard
for the same reason.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, Pressingp
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.
I have created a function to perform this action, place it on your
~/.vimrc
.OBS: If you are using neovim you also need some clipboard manager like xclip. for more information type in neovim
:h checkhealth
It is also important to mention that not always a simple
y
will copy to the clipboard, in order to make every copy feed+
wich is "Clipboard Register" try to set::set clipboard=unnamed,unnamedplus
. For mor information see::h unnamed
.Here more information on vim wikia.