Many of the answers here do not directly address the question. The respondent wants to know how to remove up to the first non- whitespace character. Some of the answers will technically work, but let's see how to do this explicitly.
The following examples demonstrate how to do this in normal mode with variations that account for the starting position of the cursor. The u̲nderlined c̲haracters indicate the cursor position:
d w : foo_ bar → foob̲ar
The d elete w ord command described in other answers is great for deleting to the next character without spaces when our cursor is in front of the target.
d b : foo b̲ar → b̲ar
Naturally, we want to try inverting d w to delete back before the first character without a space before the cursor. However, as shown above, the d elete b ack-word command deletes more than we expect - it also erases the previous word. For this case, we must use:
d T <?> : foo b̲ar → foob̲ar
... where <?> is the first character without spaces before the cursor. The d elete back-un T il command erases everything before, but does not include the <?> Character, which in this case is the o at the end of "foo".
d T <?> : foo_ bar → foob̲ar
Like the previous command, we can use d elete un T il (with lowercase "t") to remove characters forward to the next character <?> ( B in the string "for this example). To achieve this result, the same result is achieved, as d w .
d i w : Foo _ bar → foob̲ar
If our cursor is in the middle of a space, we can use the d elete i nner w ord command to remove spaces from both sides.
d / <?> ↵ : foo_ \n bar → foob̲ar
If the spaces we want to remove include line breaks, we can use the d elete command above to match the <?> Pattern, where the pattern in this case is only the first character without spaces. As shown, press Enter to execute this command.
When the first character without spaces appears at the beginning of the line after the break, Vim will remove the space, but leave the target on the next line. We need to add J to the above command in J in lines (uppercase "j").
d / <?> ↵ J : foo_ \n bar → foob̲ar