1

I want to delete whitespace backwards until end of previous word.

Say, I have the cursor on the character "d" in the word "dog":

horse cat dog

If I press Ctrl-W (Insert mode) or db (Normal mode), then "cat" is deleted, which I don't want.

Any ideas?

1

In normal mode:

cTt

Then press space

| improve this answer | |
  • This only works when the previous word ends in "t". – Andy Stewart Nov 12 at 16:35
3

How about hdiw? I.e. move into the space and then delete the "word" formed by the whitespace. That will give you:

horse catdog

To keep 1 space between cat and dog, the best I can think of is ge2ldw, i.e. go to the end of the previous word, move to the second space in the gap, and delete to the start of the next word.

| improve this answer | |
1

Using Vim's jump to first letter in line can be useful in situations like this.

dTt

delete backwards until you reach letter t, but dont include letter itself.

| improve this answer | |

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.