1

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.

1
  • 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, 2012 at 6:57

1 Answer 1

1

Not really, but you can improvise: bXde

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .