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

KeysWhat they do
ggVGSelect every line
ggdGDelete everything, no selecting
:%dSame, as a command
:%yCopy everything
ggVG"+yCopy 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