How do I move the cursor to the end of a line?
Answer
$
Explanation
The $ command moves the cursor to the last character of the current line. It is one of Vim's most fundamental motions and is used constantly for navigation and as part of operator-pending commands.
How it works
$moves to the last character on the current line- It does not move past the newline character — the cursor lands on the final visible character
- With a count,
2$moves to the end of the next line (count - 1 lines down)
Example
Given the text with the cursor on the T:
The quick brown fox
Pressing $ moves the cursor to x, the last character on the line.
Tips
- Use
0to move to the first column of the line (column 1) - Use
^to move to the first non-blank character of the line - Combine with operators:
d$orDdeletes from the cursor to the end of the line,c$orCchanges from the cursor to the end of the line,y$yanks to the end of the line - Use
g_to move to the last non-blank character of the line (useful when trailing whitespace is present) - Use
Ato jump to the end of the line and enter insert mode in one keystroke - In visual mode,
$extends the selection to the end of the line