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.
After the update, Vim can be installed as:
Now we will create a file using the vim editor.
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:
In our case, the command would be as:
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.
Conclusion
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.