Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vi

shortcut

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?

like image 652
user2045447 Avatar asked Feb 06 '13 04:02

user2045447


People also ask

How do I navigate to the end of a line in vi?

Short answer: When in vi/vim command mode, use the "$" character to move to the end of the current line.


2 Answers

After opening a file using vi

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

and

2) Press g twice to go to the beginning of the file

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

like image 59
Vivekanand S V Avatar answered Dec 09 '22 01:12

Vivekanand S V


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

like image 29
Fred Thomsen Avatar answered Dec 09 '22 01:12

Fred Thomsen