Learn Vim / How to Jump to a Specific Line in Vim

How to Jump to a Specific Line in Vim

The answerType the line number then G — e.g. 10G jumps to line 10. Or use :10 and Enter.

Try it on a real buffer

Counting j presses is for tourists. Jump straight to line 10 with 10G (or :10 and Enter), then delete that line with dd.

line  1: keep
line  2: keep
line  3: keep
line  4: keep
line  5: keep
line  6: keep
line  7: keep
line  8: keep
line  9: keep
line 10: DELETE ME
line 11: keep
line 12: keep

Canonical solution: 10G dd · par: 5 keystrokes (vimgolf rules — every keypress counts).

Why it works

G goes to the last line, gg to the first, and a number before G goes to that exact line. Ex commands work too: :10 jumps to line 10.

Variations

KeysWhat it does
10Gjump to line 10
:10same, as an ex command
ggjump to the first line
Gjump to the last line
50%jump halfway through the file

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

Practice free — no signup →

Keep going