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.

grodzik
  • 4,588
  • 19
  • 27
rtl33
  • 81
  • 1
  • 2

2 Answers2

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.

Tumbler41
  • 7,746
  • 1
  • 21
  • 48
  • 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 '17 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 '17 at 07: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

balki
  • 355
  • 1
  • 8