In Vim, I know d$, that deletes everything to the end of line.

But how can I delete all text from the current cursor position until the next space? dw doesn't work, since it treats symbols like colon as separator as well.


dW (capital W) or more generally you can do df followed by the character to search for, in this case space. You can also use t instead of f to delete up to but not including the found character. And if you capitalize the F or T, they work backwards.

  • 1
    +1 for dt, d t space worked for me
    – daisy
    Nov 5 '12 at 6:53
  • 1
    dE deletes to the end of the WORD
    – Parsa
    Aug 3 '14 at 21:11

You can also delete until a search string, thus d/<Space> will delete until, but not including, the first space from the cursor position.

  • Anybody an idea on how to escape a space in the code-tics?
    – Bernhard
    Nov 5 '12 at 6:52
  • 1
    Just use the same convention as the Vim help file: d/<Space>.
    – hammar
    Nov 5 '12 at 12:29

The best (fewest keystrokes) way is


This deletes all text from the current position until the next space. From the help (:h E)

E                       Forward to the end of WORD [count] inclusive.
                        Does not stop in an empty line.
A WORD consists of a sequence of non-blank characters, separated with white
space.  An empty line is also considered to be a WORD.
  • ... and what does this do?
    – muru
    Sep 27 '15 at 11:28
  • It does exactly and precisely what the O.P. requested.
    – Wildcard
    Sep 27 '15 at 11:34
  • Holy smokes! It does? I can't believe it!
    – muru
    Sep 27 '15 at 11:35
  • Oh. I suddenly understand the sarcasm...I didn't realize how old this question was when I posted. Sorry, I'm new here.... :(
    – Wildcard
    Sep 27 '15 at 11:42
  • Posting to an old question is not a problem. But posting a command without any explanation is.
    – muru
    Sep 27 '15 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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