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
I have created a function to perform this action, place it on your ~/.vimrc.
fun! CopyBufferToClipboard()
%y+
endfun
nnoremap y :call CopyBufferToClipboard()
command! -nargs=0 CopyFile :call CopyBufferToClipboard()
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.