vimtricks.wiki Concise Vim tricks, one at a time.

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

  • D is equivalent to d$
  • d triggers 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 C to delete to end of line and enter insert mode (equivalent to c$)
  • Use d0 to 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

Next

How do I edit multiple lines at once using multiple cursors in Vim?