In Linux, the Vim editor is furnished with numerous operational tools that allow its users to navigate around large files of data and jump to the top or bottom without any hassle.
How to Jump End of File in Vim
Vim editor has become popular among users because of its user-friendly functions. The process of navigating directly to the bottom of a file using the arrow keys or scrolling is quite slow and irritating when dealing with large data. Vim editor has multiple ways to do that; let’s go through all of them.
(We are performing this on Ubuntu 22.04 version).
Get the Vim Editor on the screen by typing Vim in a terminal:
Open the file you’re working on; we assume a sample file containing a number of days in a month.
1. Jump the End of the File Using Shift + G
The shortest and most common way to jump to the end of the file is using the G key. Open the file in Vim, and remove the insert mode by hitting the ESC button.
The below screen shows the data file in the file:
Now, press the keys Shift + g to reach at last line of the file:
2. Jump to the End of the File Using the End Key
Another way to move to the end of a file is by using the Control + End key:
3. Jump to the End of the File Using G+A Keys
The following keys allow you to navigate to the last line of the file and switch the command mode to insert mode:
By executing the above syntax, you would be able to add, delete, or update the document.
4. Jump End of File Using Closed Brackets
Enter the closed brackets 2 times instantly and this will shift the cursor at the end of the file:
5. Jump End of File Using $ Command
Execute the following $ command to move the cursor to the last line of the working file. This will execute when you’re in normal mode:
Now, hit the Enter button to run this:
Bonus Point
How to Get Back to the Start of a File in Vim
We also have multiple shortcut keys in Vim to move back to the top of the file.
1. Pressing the gg key:
To get back to the top of a file in Vim editor, the commonly used way is pressing “g” two times when the normal mode:
2. Pressing the 1+G keys
You can also press the 1 + Shift + g keys simultaneously to move to the top line of file:
3. Pressing the Home Button
Press the Control button along with the Home button to navigate to the first line in the Vim editor:
4. Pressing Open Brackets
Use the open brackets by hitting them twice to go to the top line of the file; make sure you are in the normal mode first through the “Esc” button:
5. Pressing the 1 Button
Type :1 in the Vim editor when you’re in normal mode, this will redirect you toward the first line of the Vim editor:
Conclusion
While working with a huge file’s data, you might find it time-consuming and irritating to move to the last line of the file using a cursor or arrow keys. Vim a popular editor in the Linux operating system allows its users to do this using numerous ways.
This guide has mentioned all of the possible ways to navigate quickly at the end of a file in Vim editor. These ways include using the Shift + G keys, pressing Control + End keys, through Closed Brackets, and $ command. Not only this, we have also mentioned how to get back to the top of the file through multiple methods.