Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Consider this code:

foo = (int)someVariable - 42;
bar = someFunction('someArgument') + 42;

By placing the cursor on the leading character of someVariable and someFunction we can experiment with dw, daw, and diw. We can see that the commands have the following behaviour regarding the deletion of whitespace from the Left and Right sides:

      L?   R?
daw   Y    Y
 dw   .    Y
diw   .    .

L?: Deletes whitespace from the left
R?: Deletes whitespace from the right

The daw command will delete whitespace from either side of the text, whereas dw will only delete from the right and diw will not delete whitespace from either side. Is there a command that will delete whitespace only from the left, but not from the right?

Note that this is not an issue that I am having with VIM, but rather my experimentation to learn the editor better.

share|improve this question
I'm not aware of such a command. In most languages, a space is used after a word to separate it from the following. This is the rule more or less followed by Vim. That said, it appears to work differently in code than in prose: daw with the cursor anywhere on someFunction will also delete the space between it and =. If you remove this space, your code still means something while you'd get gibberish if you'd removed the space between lorem ipsum. – romainl May 17 '12 at 6:57
up vote 1 down vote accepted

Not really, but you can improvise: bXde

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.