Vi/Vim End Of Line
Thursday, Aug 8, 2024 | 3 minutes read | Update at Thursday, Aug 8, 2024
Vim/Vi is very popular command line text editor for Linux. Vim/Vi provides different shortcuts for different operations. Jumping end of the line in Vim/Vi is popular operation and can be done with different shortcuts or command. In this tutorial we examine different ways to jump end of the line in Vim/Vi
-
Move to the end of the current line: We can use the
$
key directly jump to the end of the current line. This will jump end of line where cursor is located.- Command mode:
$
Moves the cursor to the end of the current line.
- Command mode:
-
Append text at the end of the current line: The
A
can be used to jump end of the line for the current line and start append mode. We can append new content to the end of line easily with theA
.- Command mode:
A
Moves the cursor to the end of the line and enters Insert mode.
- Command mode:
-
Delete from the cursor to the end of the line: We can jump end of the line by deleting from the cursor current location to the end of line. After this operation the cursor will be end of the line.
- Command mode:
D
Deletes from the cursor position to the end of the line.
- Command mode:
-
Change (replace) text from the cursor to the end of the line: We can jump end of the line from the cursor current location to the end of line and the INSERT mode will be start which simply means we are replacing from the cursor location to the end of line.
- Command mode:
C
Deletes from the cursor position to the end of the line and enters Insert mode.
- Command mode:
-
Yank (copy) from the cursor to the end of the line: We can use
y$
to copy from the cursor to the end of the line.- Command mode:
y$
Copies from the cursor position to the end of the line.
- Command mode:
-
Move to the end of the next line: Some times we may need to jump to the next lines end of line. We can use
j$
to jumpx end of the next line.- Command mode:
j$
Moves the cursor down one line and then to the end of that line.
- Command mode:
-
Move to the end of the previous line: We can use the
k$
shortcut in order to move end of the previous line.- Command mode:
k$
Moves the cursor up one line and then to the end of that line.
- Command mode:
-
Delete from the cursor to the end of the line in visual mode: We can use
d$
to delete from cursor current location to the end of line.- Visual mode:
d$
Deletes the selected text from the cursor position to the end of the line.
- Visual mode:
-
Replace a character at the end of the line:
- Command mode:
$r
Moves the cursor to the end of the line and allows you to replace the last character of the line by typing the replacement character.
- Command mode:
These commands showcase various ways to navigate to, modify, and interact with the end of a line in Vim, providing efficient text editing capabilities.