Vim or Vi is a command-line text editor which is very different from most of the popular text editors which are GUI-based. For GUI-based text editors generally, a mouse pointer is used for navigation over files like the jumping end of the file. Vim or Vi uses different commands and keys for navigation. In this tutorial, we examine different ways to move or jump to the end of a line in Vim/Vi using different commands and key shortcuts.
End Of Line Key Shortcuts For Vim/Vi
You can use the following table in order to move the end of the line of different lines.
KEY SHORTCUTS | DESCRIPTION |
---|---|
$ | Move end of the current line. |
gg$ | Move the end of the first line. |
G$ | Move the end of the last line. |
11G$ | Move the end of the line number 11 |
Move End Of Current Line
Vim provides the key for the move or jump end of the line. Take the following steps to jump to the end of the current line. The current line is the line where the cursor is located.
- Press the ESC key.
- Press $ (dollar sign) in order to move the end of the current line where the cursor is located.
Move End Of Current Line and Insert Mode
The A
key can be used to go end of the current line and change to the Insert Mode
where we can start directly typing which is inserted to the end of the current line.
- Press
ESC
key. - Press
A
in order to move end of the current line and change to Insert Mode.
Move End Of First Line
We may need to end the first line from anywhere in the file. Even the cursor is located end of the file you can move the end of the first line with the following steps.
- Press the ESC key.
- Press gg to move the first line and press $ to move the end of the line.
Move End Of Last Line
We may need to end the last line from anywhere in the file. Even the cursor has located the start of the file you can move the end of the last line with the following steps.
- Press the ESC key.
- Press G to move the last line and press $ to move the end of the line.
Move End Of Specified Line
We can also move any of the specified line number ends of the line. Just follow these steps. In the following example, we will move the end of line number 11.
- Press the ESC key.
- Press 11G to move the last line and press $ to move the end of the line.