Vim
Copy all the lines to clipboard
y G
or
:%y
Cut the whole file
d G
Yank N lines
The usual mnemonic: {N}yy. For example, 10yy yanks the current line plus the next 9 lines (10 lines total).
From the current line downward
yy # yank the current line
3yy # yank 3 lines starting from the current line
5yy # yank 5 lines starting from the current line
Pattern: {N}yy, where N is the number of lines.
In Vim, Y is a synonym for yy. Neovim maps Y to y$ by default (yank to end of line), so use yy to yank a whole line.
Yank to a line number
y5G # yank from the current line to line 5
yG # yank from the current line to the end of the file
ygg # yank from the current line to the start of the file
Visual mode (most intuitive)
V # enter linewise visual mode
j / k # move the selection up or down
y # yank
Or V, then 3j, then y: current line plus 3 lines down, 4 lines total.
Easy to mix up
yy # yank the current line
y$ # yank from the cursor to the end of the line, not the whole line
y0 # yank from the cursor to the start of the line
Paste
p # paste after the cursor / on the next line
P # paste before the cursor / on the previous line