How to jump to a line in a Vim

Writing a code of about 600 lines, suddenly we need to make some amendments in line 106, what should we do? With the help of moving the cursor to line 106, we go to line 106, but it will take time. Can we directly jump to line 106 and save our time? Yes! The Vim editor provides us a way to jump to the line and make modifications. We can jump the start and the end of the files by using a simple command. We can also find out the specific word in the Vim editor and directly jump there.

Vim (Vi Improved) is an editor used to create, open, edit, and save any type of text. Vim is one of the reliable and efficient editors mainly used on Unix to create and edit text files.
This write-up enables us to understand how to jump to the specific line using Vim editor.

Installation of Vim editor

Before using the Vim editor, we will install it. Before the installation of the Vim editor, we will update the repository.

$ sudo apt update

After the update, Vim can be installed as:

$ sudo apt install vim -y

Now we will create a file using the vim editor.

$ vim myFile.txt

Edit the text in the editor by pressing the “I” to enter the insert mode, type the text, and exit the editor by saving the file using “:xa”.

Jump to particular line commands in Vim : Once the installation is complete, now we will discuss the jump commands. We can jump to the specific line of the text file by using a command whose general syntax is:

$ vim +[line number]  [file name]

In our case, the command would be as:

$ vim +2 myFile.txt

When we press Enter to execute the command, the editor will be open and we can see the cursor is pointing at the start of line 2.

If we are in the vim editor, then simply do this, “Press the ENTER key, write the Line number, and press Shift+ g”:

Again the output is the same.

Jump to the start of the particular line of the text : If we have a text of several hundred lines and we want to go to the start of a line to edit it, we simply use, “Shift + ^“:

Jump to the end of the particular line of the text : We can jump to the end of the specific line by going on a line and do the following; “Shift + $”:

Jump to a line by a specific word : If we want to jump to a line having some specific words to replace those words we can do so by using,” / [type the word you want to find]”:

To find the next line where the word is present; ”Type “n” and press ENTER key”:

The outcome showing the cursor moving to the next line where the word laptop is present.


Finding a specific word in a text file or code of hundreds of lines is no less than a hassle. The problem can be addressed using a feature-rich vim editor. This article presented various methods to make modifications in a file using vim editor, such as jumping to a specific line, finding a word, and moving the top and end of a file through various shortcut keys.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.