Delete from cursor to end of line in `vi`

D (=Shift+D)

The command DW will delete from the current cursor position to the beginning of the next word character. The command D$ (note, that's a dollar sign, not an 'S') will delete from the current cursor position to the end of the current line. Shift+D is a synonym for D$.


As others have mentioned: you can use d$ or D (shift-d) to delete from the cursor position until the end of the line.

What I typically find more useful is c$ or C (shift-c) because it will delete from the cursor position until the end of the line and put you in [INSERT] mode.


One of the nice things about vi is its logical command structure. d followed by a motion command deletes to the target of that motion. $ moves to the end of the line (mnemonic: like in regexps). So d$ deletes to the end of the line. Similarly, e moves to the end of the current word, and w moves to the beginning of the next word; so de deletes the end of the current word, and dw additionally deletes the following whitespace.

Tags:

Vi

Vim