navigation

gg / G

gg jumps to the first line of the file; G jumps to the last line. Prefix G with a number to jump to that absolute line — the fastest way to reach a specific line from a stack trace.

gg  G  (normal mode)

Variations

Keystroke Effect
42G Jump to line 42
:42<Enter> Alternative — jump to line 42 via command mode
ggVG Select the entire file (gg then visual-line to end)
gg=G Reindent the whole file

Examples

gg

Go to line 1

G

Go to last line of file

100G

Jump to line 100

Gotcha

G without a count goes to the LAST line, not line 0. If you accidentally type Gg or gG, nothing happens — G must come after the count.

Related

← All Vim commands · Vim cheat sheet