TL; DR: If you want to copy the text in Vim to the system clipboard type g g V g " * y . Explanation below ...
Vim works in the terminal and, depending on how you use it and what type of Vim you use, it is not designed to select text with the mouse and copy and paste in the traditional way.
If you want to select all the text using Vim, use g g V g y (pay attention to the upper case V g in the middle). This command moves the cursor to the top of the file, switches to visual mode, moves to the bottom of the file (thus, selecting all the text), and then yanks (copies) it. Then you can use p to enter (insert) this code, but only inside Vim.
If you want to copy to the clipboard for use somewhere outside of Vim , try the following:
First select everything using the commands described above, but without the final y : ( g g V g ). Then press " * y . Now it should copy it to the operating system clipboard, and you can simply paste ( Ctrl / Cmd + V ) anywhere except Vim. This may vary depending on what settings you have for Vim but it should work.
A brief description of the commands used. g g goes to the beginning of the file. V goes into visual mode line by line. g comes to the end of the file. y yanks (copy) the text, but not to the clipboard. p puts (inserts) the text.
More advanced (i.e. cool) stuff:
" allows you to access the registers. For example, " a provides access to register a.
* is the system clipboard, therefore "* provides access to the system keyboard. Therefore, "*y occupies the system clipboard.
Gordonium
source share