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)]
Type "gg" in command mode. This brings the cursor to the first line.
If you are using gvim, you could just hit Ctrl + Home to go the first line. Similarly, Ctrl + End goes to the last line.
Source: Stackoverflow.com