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

How do I delete from the cursor to the end of a word?

Answer

de

Explanation

The de command deletes from the cursor position to the end of the current word. It combines the d (delete) operator with the e (end of word) motion.

How it works

  • d triggers the delete operator
  • e moves to the last character of the current word
  • Together they delete everything from the cursor through the end of the word, leaving any trailing whitespace intact

Example

Given the text with the cursor on the q of quick:

The quick brown fox

Pressing de results in:

The  brown fox

The characters quick are deleted but the space after the word remains.

Tips

  • Use dw to delete from the cursor to the start of the next word (includes the trailing whitespace)
  • Use de when you want to preserve the space after the word
  • Use d2e to delete through the end of the second word ahead
  • Use ce to delete to the end of the word and enter insert mode
  • Use dE (uppercase) to delete to the end of a WORD (whitespace-delimited, treating punctuation as part of the word)
  • If the cursor is in the middle of a word, only the portion from the cursor onward is deleted

Next

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