How do I go to first line in a file in vim ?
4 Answers
In command mode (press Esc if you are not sure) you can use:
- gg,
- :1,
- 1G,
- or 1gg.
-
Great! So much easier than : 1 Shift-g– user2493235Dec 23, 2016 at 20:22
-
3
gg
does a "soft" beginning of first line, if there is whitespace you'd need to dogg0
Sep 13, 2019 at 4:34
Type "gg" in command mode. This brings the cursor to the first line.
-
2why does
gg
do that? I've found usually vim commands are composed of others so maybe there is a reason its doubleg
than singleg
. Jan 20, 2017 at 23:57 -
1
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)]
If you are using gvim, you could just hit Ctrl + Home to go the first line. Similarly, Ctrl + End goes to the last line.
-
8
G
will go to the last line andG$
will go to the end of the file.G
vsG$
?