Vim Command to Select All

This is a compact and powerful command. We're telling vim to yank the entire file from the first line to the last.

One & Done

:%y yank every line in the file

Parting Thoughts

% is an interesting operator in command-line-mode. It is equivalent to 1,$ (the entire file). So, we’re really just passing a range to the yank operator. This shows us how easy it would be to yank any lines without a file.