However, beginners sometimes don’t know how to move between the lines in the Vi editor, and they end up losing the data of the text files. So, in this quick guide, we will explain the different ways to move to the end of a line in Vi editor.
How to Move to the End of a Line in Vi Editor
There are a few commands that you can use to go to the end of a line in the Vi editor. However, you can only execute them in the βcommandβ mode. Let’s divide this section into multiple parts to learn about those commands.
1. The β$β Key
The “$” in the Vi editor moves the cursor to the end. Go through the following steps to know its usage:
Open a file in the Vi editor and ensure that you’re in the βcommandβ mode by pressing βESCβ. If you are in the βinsertβ mode, ESC will switch it to the βcommandβ mode. Otherwise, it doesn’t affect anything.
Select the line whose end you want to locate. Then, make the dollar sign ($) by pressing the βShiftβ and β4β keys.
Now, if you want to add a text at the end, press the βIβ key which opens the βinsertβ mode.
2. The βAppendβ Command
The βappendβ text command in the Vi editor is used to add a text at the end. Open a file in βcommandβ mode in the editor and then press the βShiftβ and βAβ keys.
3. The βEβ Key
The “e” command in the Vi editor takes you to the end character of a word. However, you can use it to go to the end of a line. First, take the cursor to the desired line using the arrow keys. Then, press “e” repeatedly until you reach the end.
After that, you can press the βIβ key to enter the βinsertβ mode to add more text at the end.
Conclusion
Vi editor’s command-driven environment might intimidate you at first, but it can significantly boost your productivity as you master the commands. You can perform all the text editor operations with the simple commands. After getting the correct information about moving to the end of a line in Vi editor, you can view, edit, or insert the text efficiently.