File Motions

gg, G, {n}G โ€” jump anywhere in the file.

Keys: gg, G, {n}G, :{n}

gg goes to line 1. G goes to the last line. {n}G or :{n} goes to line n.

Three jumps cover most navigation across a file: top, bottom, and a specific line number.

Go to first line
KeyNote
g
g
Go to last line
KeyNote
G
Go to line {n}
KeyNote
{n}
G
Go to line {n} (Ex form)
KeyNote
:
{n}
Enter
gg โ€” top of file
G โ€” bottom of file
{n}G โ€” go to line n

Reference

Key Action
gg First line
G Last line
{n}G Line {n}
{n}gg Line {n} (alternate)
:{n}Enter Line {n} via Ex
{p}% Line at {p} percent of file

Worked example โ€” gg G

Top and bottom of file.

Step 1 ยท Middle of file.
Middle of file.
Step 2 ยท gg ยท gg โ€” top.
gg โ€” top.
Step 3 ยท G ยท G โ€” bottom.
G โ€” bottom.

With a count: 3G or :3<CR> jumps to line 3.

โ–ถ Try this in the simulator

See also: The Jump List, Ex Ranges