How do I delete till non-whitespace in vim?

Singlestone picture Singlestone · Aug 7, 2011 · Viewed 24.3k times · Source

I'm looking for a command to delete from the cursor to the first non-whitespace character on the same line. I've googled for a while and tried several possibilities. No joy. Does someone out there know how to do this?

Answer

richardolsson picture richardolsson · Aug 7, 2011

The sequence dw will delete all characters from the cursor until the next word. This means that if you execute the command while standing in the middle of a word, it will delete the remainder of that word and subsequent whitespaces. May or may not be what you're looking for.