Step 2 of 6

3. Basic Navigation

Navigating to specific lines

We might find ourselves wanting to jump to the very top, very bottom, or to some specific line in a file. Vim provides us with some commands for doing this.

Often you know exactly which line you want. For example: most compilers will tell you which line an error is on if your build fails. With Vim, you can jump directly to the line of interest — say line 10 — by hitting 10G in normal mode.

If you want to jump to the bottom of your file, you can do this by typing G in normal mode.

And if you want to jump back to the top, type gg.

Work through the checklist below — each jump is checked off the moment you make it.

  1. Jump to line 10 A count, then a capital G — type 10G.
  2. Jump to the bottom of the file A capital G on its own — press G.
  3. Jump back to the top Press g twice, quickly.
Jump to line 10 A count, then a capital G — type 10G.

Next: Jump to the bottom of the file

Loading editor…