Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go to first line in a file in vim?

Tags:

vim

editor

line

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

like image 218
Jean Avatar asked Mar 31 '11 22:03

Jean


People also ask

How do I go to the beginning of a file in vi editor?

Key in 1 + G and it will take you to the beginning of the file.

How do I jump to a specific line in Vim?

If we are in the vim editor, then simply do this, “Press the ENTER key, write the Line number, and press Shift+ g”: Again the output is the same.

How do you go to the front of a line in vi?

Shift+I or ^ will move cursor to beginning of the text in the line.

How do I get to the top of the file in vi editor?

Instead of that, you can also use the Esc + Ctrl + Home key combination to move your cursor to the first line of any file.


2 Answers

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

  • gg,
  • :1,
  • 1G,
  • or 1gg.
like image 128
Lazer Avatar answered Oct 09 '22 21:10

Lazer


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

like image 40
andrew Avatar answered Oct 09 '22 22:10

andrew