> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Go to Beginning or End of File in Vim
- URL: https://linuxhandbook.com/beginning-end-file-vim/
- Published: 2022-03-07T06:37:49.000Z
- Updated: 2025-08-22T17:34:28.000Z
- Description: Knowing to move to top or bottom of a file is extremely useful while dealing with large text files in Vim.
- Author: Abhishek Prakash
- Tags: Vim Tips, #docs-col, #group-additional-tips

If you open a very long file in Vim, it can get tough to navigate the file. 

It is good to know how to move the cursor from anywhere in the file to either the first line or to the last line.

| Move             | Keys              |
| ---------------- | ----------------- |
| To the beginning | gg or \[\[        |
| To the end       | shift + g or \]\] |

You need to be in normal mode (also known as command mode) to use these keyboard shortcuts. Use the `Esc` key to enter the command mode, and then use the above-mentioned keys.

Let's go a bit in detail.

## Jump to the last line in Vim

Just like Apple's phrase "There's an app for that", in Vim, "There's a command for that".

It does not matter which row or column you are in Vim, to move your cursor to the last line, simply press an uppercase `G` (i.e. Shift and g key together) in Normal mode, and your cursor will move to the first character of the last line.

Another way to jump to the end of a file is by using the `Esc + Ctrl + End` or `]]` key combination.

## Jump to the first line in Vim

There are several ways you can jump to the first line in Vim.

Since these are Vim commands, make sure that you are in Normal mode (use Esc key) before pressing any keys.

To jump back to the first line of the file, you can use either one of the following commands:

```vim
1G
```

This command tells vim to move the cursor to line 1, as specified in the command.

```vim
gg
```

Typing `gg` has the same impact on cursor location - the cursor is moved to the first column of the first row.

I prefer using `gg` instead of `1G` as it is easy to type `2G` and end up on the second line.

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

## Conclusion

This article covers how you can move your cursor from anywhere in the file to the beginning or end of the file.

If you are interested in learning more than just the [Vim Basics](https://linuxhandbook.com/basic-vim-commands/), I highly recommend using this training course by Jovica Ilic.

[Mastering Vim Quickly - Jovica IlicExiting Mastering Vim Quickly From WTF to OMG in no timeJovica Ilic![](https://jovicailic.org/wp-content/uploads/2017/11/book_video_ebooks-1.jpg)](https://gumroad.com/a/322499699?ref=linuxhandbook.com)