Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I've probably looked over this a million times in all the VI documents I've read, but I can't seem to find the delete from cursor to end of line command.

share|improve this question
You've got a typo here - you say "end of line" in the title, but "end of word" in the question. – Jefromi Nov 30 '10 at 17:50
up vote 197 down vote accepted

The command dw will delete from the current cursor position to the beginning of the next word character. The command d$ will delete from the current cursor position to the end of the current line. D is a synonym for d$.

share|improve this answer
Yeah I know of dw, but I guess I just assumed there would be a "delete the rest of this line" command. For example my line has ip=| with | being the cursor location. Is there a command that will delete all the – Falmarri Nov 29 '10 at 21:03
@Falmarri - I apologize, I must have misunderstood your question. There is a command for that: d$ – Tok Nov 29 '10 at 21:04
D (Shift+d) is also a synonym for d$. – Neth Nov 29 '10 at 22:06

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.

share|improve this answer
I'm used to emacs style so I was trying de which obviously wasn't working. I forgot about $ – Falmarri Nov 29 '10 at 22:13
@gioele I use <kbd> for actual keys, not for command sequences. E.g. <kbd>Ctrl</kbd>+<kbd>C</kbd>, but d$. – Gilles Apr 29 '14 at 9:42
@Gilles You are right. I've just tried d^ and it deleted from cursor position to the line begin. – ka3ak Apr 2 at 11:57

You probably want to use D. Move the cursor to the first character you want to delete, then hit shift-D. Everything gone. Actually, it's in the default cut buffer, so you can P or p paste it back in.

I use Dp (delete to end of line, then put it back), move to the end of some other line, then p again to paste the same text in at the end of this other line. Works wonders in config files, where you need to put some complicated URL in two or more places.

share|improve this answer
It's probably a minimal Vim he uses anyway. – polemon Dec 3 '10 at 9:17

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.