y

:y will yank the current line regardless of your cursor position.
If you wish to paste the yanked line, press p or P.

:y also accepts a range.
:1,$y will yank the entire file as $ represents last line in the file.
:5,10y will yank lines 5 through 10.
:'<,'>y will yank from the beginning of the last selection, through the end of the last selection.

Further Reading

:h :y

More Gifs