Learn Vim / How to Select All in Vim

How to Select All in Vim

The answerPress ggVG — top of file, line-wise visual mode, extend to the last line.

In vim you rarely need select-all: operators take motions directly (ggyG copies the whole file with no selection step). But when you want to see it, ggVG is the move.

All the ways

KeysWhat it does
ggVGselect the whole file
ggyGcopy the whole file — no selection needed
:%ycopy all lines via ex command
ggVG"+yselect all + copy to system clipboard
▶ live vim buffertarget 4 keystrokes
Copy the entire file: gg to jump to the top, then yG yanks from here to the last line. (Or try :%y — or ggVGy with visual mode.) The file must stay unchanged.

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Take everything” mission takes about a minute.

Sign in free to practice →

Keep going