8

I use Vim 7.4.576 on debian8. I don't grasp the concept of deleting words backwards.

Here is some text. Cursor position is on "that" (the pipe symbol)

this is a new text on th|at line.

How can I delete the previous words, so as a result the sentence will look like this:

this is a line

Is this the best solution? b4dw

......or is there a shorter way, so that i can skip the first b?

thanks in advance.

1
  • Did you mean 4b4dw to get that result?
    – Philippos
    May 12, 2017 at 6:04

2 Answers 2

8

You can use b as a motion for the delete instead of the w to delete backwards.

w4db

See :help {motion} for more info.

2
  • okay...b deletes the word before the cursor, and w also the word in the cursor. so you have to count correctly.
    – rtl33
    May 11, 2017 at 23:19
  • 1
    Instead of counting, you can also go with w, then db and repeat that with . (dot) operator (only db will be repeated). Maybe it's more keystrokes, but it may be faster than stopping and counting how many words to delete, plus if you want to delete 4 words, and later decide that one more needs to be deleted, then it's just one more . to press, and if you miscount, than it's just u to press, and only one word deletion will undone.
    – grodzik
    May 12, 2017 at 7:32
1

You can also go to insert mode and type ctrl + wwww. Not sure if it will work with gvim. Useful if you are already in insert mode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.