How to jump to the end of file in VIM

How to jump to the end of file in VIM

Overview

This article will act as a simple guide to demonstrate how to jump to the end of file in VIM. Vim is a powerful text editor but it requires time and a learning curve to master it. Vim is made in a way that all commands, functions and editing is done via keyboard. Because of that, Vim has a lot of keyboard shortcuts to execute all those commands and functions. Today we’ll demonstrate how to jump to the end of a file in Vim and some other commands on how to move down the file(or in another words move cursor page up and page down in vim). Small note: These commands also are valid for VI and NVIM.

If you’re interested, you can check out this post which showcases some of the essential editing and navigation VIM commands.

Before we proceed, we must understand that Vim has multiple working modes and that is important because not all commands can be executed in all modes. in this post we’ll cover – Normal, Command, Visual and Insert mode, which are modes for everyday usage.

  • Normal mode is a default mode when you open Vim and from it you access other modes.
  • Insert mode is the text editing mode – adding and removing text by typing.
  • Visual mode is used for text selection and bulk editing.
  • Command mode is used to run Vim global commands(Vim preferences), text manipulation, pattern search and so on.

The commands we’ll run here are all executed in the Normal mode.

To make sure you’re in Normal mode, type the “Esc” key a couple of times.

jump to the end of file in VIM
Normal mode
jump to the end of file in VIM
Insert mode(NOT for navigation)

How to jump to the end of file in VIM

While in Normal mode, type the keys – “Shift+g” in order to jump to the end of the file. Essentially the command is to type the capital letter “G

Jump to the specific line in VIM

In Vim, the letter “g” is assigned to the commands to move cursor and there are other command variations to execute to move. There’s a key combination of how to jump to the specific line.

To execute it and jump to the specific line, type the number of the line and then the capital “G”. So, the command should look like this:

12+Shift+g

Jump to the end of line with “Ctrl+End”

Vim also accepts the global keyboard command shortcuts for text navigation in text editors and that allows us to jump to the of file in Vim using the keyboard shortcut – “Ctrl+End

Jump to the end of line by executing the Vim command :$

Besides the keyboard shortcuts, in VIm we can jump to the end of file by executing the Vim command, which is:

:$”

jump to the end of file in VIM
jump to the end of file in VIM with the VIM command

In order to execute a command in Vim, type the colon key “:”. The colon key opens up the Vim command prompt and then when the command prompt is visible, type the dollar character “$” to jump to the end of the file.

Jump to the start of file in VIM

To jump to the start of file in VIM, we will just reverse some commands we mentioned earlier. All these also need to be run in the Normal mode in Vim.

Vim shortcut – “gg

The command is lowercase letter “g” typed two times. 

Vim shortcut – “1G

We can use the jump to the specific line method as earlier to jump to the beginning of the line. The command is: “1+Shift+g

Global keyboard shortcut – “Ctrl+Home

Summary

To conclude the article, we reviewed the steps on how to jump to the end of file in VIM and also covered some commands on how to jump up and down in VIM(move cursor page up and page down in vim), how to jump to a specific line and to the start of file too.

Thank you for your time…

You may also like...

Leave a Reply

Your email address will not be published.