Is there a short cut for going back to the beginning of a file by vi editor?

ViShortcut

Vi Problem Overview


When reading a long file by vi editor, it would be very nice to get back to the beginning of the file by some short cuts when you really need to do so. Even ctrl+B sometimes is too slow. Does anyone know such a tool?

Vi Solutions


Solution 1 - Vi

After opening a file using vi

  1. You can press Shift + g to go the end of the file

and

  1. Press g twice to go to the beginning of the file

NOTE : - g is case-sensitive (Thanks to @Ben for pointing it out)

Solution 2 - Vi

using :<line number> you can navigate to any line, thus :1 takes you to the first line.

Solution 3 - Vi

Go to the bottom of the file

  • G
  • Shift + g

Go to the top of the file

  • g+g

Solution 4 - Vi

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

Solution 5 - Vi

Well, you have [[ and ]] to go to the start and end of file. This works in vi.

Solution 6 - Vi

To go end of the file: press ESC

  1. type capital G (Capital G)

  2. press shift + g (small g)

To go top of the file there are the following ways: press ESC

  1. press 1G (Capital G)

  2. press gg (small g) or 1gg

  3. You can jump to the particular line number,e.g wanted to go 1 line number, press 1 + G

Solution 7 - Vi

In command mode: : + 1 will take you to first line

Solution 8 - Vi

Typing in 0% takes you to the beginning.

100% takes you to the end.

50% takes you half way.

Solution 9 - Vi

I've always used Ctrl + Home (start of file) and Ctrl + End (end of file).

Works in both insert and nav modes.

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
Questionuser2045447View Question on Stackoverflow
Solution 1 - ViVivekanand S VView Answer on Stackoverflow
Solution 2 - ViFred ThomsenView Answer on Stackoverflow
Solution 3 - ViSubhashree PradhanView Answer on Stackoverflow
Solution 4 - ViparanzanaView Answer on Stackoverflow
Solution 5 - ViWesternGunView Answer on Stackoverflow
Solution 6 - ViRahul SinghView Answer on Stackoverflow
Solution 7 - VidostonView Answer on Stackoverflow
Solution 8 - ViBoerglerView Answer on Stackoverflow
Solution 9 - ViTimView Answer on Stackoverflow