Vim Scoops / Lessons / Go to a line
How to go to a line number in Vim
Type :42 and press Enter to jump to line 42. 42G does the same. gg goes to the first line and G to the last.
The keys
| Keys | What they do |
|---|---|
:42 | Go to line 42 |
42G or 42gg | Same thing, without the command line |
gg | First line |
G or :$ | Last line |
:set number | Show line numbers |
Lines count from 1, the same numbers you see with :set number turned on and in compiler errors. Each jump lands on the first non-blank character of the line.
To open a file at a line from the terminal, use vim +42 file.txt.
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