Go to first line in a file in vim?

VimEditorLine

Vim Problem Overview


How do I go to first line in a file in vim ?

Vim Solutions


Solution 1 - Vim

In command mode (press Esc if you are not sure) you can use:

  • gg,
  • :1,
  • 1G,
  • or 1gg.

Solution 2 - Vim

Type "gg" in command mode. This brings the cursor to the first line.

Solution 3 - Vim

Go to first line

  • :1

  • or Ctrl + Home

Go to last line

  • :%

  • or Ctrl + End


Go to another line (f.i. 27)

  • :27

[Works On VIM 7.4 (2016) and 8.0 (2018)]

Solution 4 - Vim

If you are using gvim, you could just hit Ctrl + Home to go the first line. Similarly, Ctrl + End goes to the last line.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJeanView Question on Stackoverflow
Solution 1 - VimLazerView Answer on Stackoverflow
Solution 2 - VimandrewView Answer on Stackoverflow
Solution 3 - VimDimiDakView Answer on Stackoverflow
Solution 4 - VimBharat LagaliView Answer on Stackoverflow