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