How do I delete from the cursor to the end of the line?
Answer
D
Explanation
The D command deletes everything from the cursor position to the end of the current line. It is a shorthand for d$, combining the delete operator with the end-of-line motion.
How it works
Dis equivalent tod$dtriggers the delete operator$moves to the end of the line
Example
Given the text with the cursor on the b of brown:
The quick brown fox jumps
Pressing D results in:
The quick
Everything from brown onward is deleted. The deleted text is stored in the unnamed register and can be pasted with p.
Tips
- Use
Cto delete to end of line and enter insert mode (equivalent toc$) - Use
d0to delete from the cursor to the beginning of the line - Use
d^to delete to the first non-blank character of the line - The deleted text goes into the default register, so you can paste it elsewhere with
p