Vim Scoops / Lessons / Select all
How to select all in Vim
Press gg to go to the top, V to select the line, then G to stretch the selection to the bottom. Now d deletes everything and y copies it.
The keys
| Keys | What they do |
|---|---|
ggVG | Select every line |
ggdG | Delete everything, no selecting |
:%d | Same, as a command |
:%y | Copy everything |
ggVG"+y | Copy everything to the system clipboard |
There's no single select-all key, because you rarely need one. Any command that takes a range can use % to mean the whole file.
Selecting first is worth it when you want to see what you're about to change.
Related
Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.
Play the full game