Vim delete motions include under the cursor

If you delete backwards in vim, it doesn't delete the character under the cursor. What do you need to do to have it delete, say, back to the last space?


Solution 1:

Just to clarify, if you are already in insert mode, CTRL-W is fast and usually what you want.

In normal mode, this may be what you're after:

Prepare to have your mind blown:

dvb

Vim makes a distinction between inclusive and exclusive motion. v toggles the "inclusiveness" or "exclusiveness" of a motion. For an example of toggling the opposite direction (inclusive => exclusive), try it with e:

dve

See :help inclusive for an explication. Until now, you thought it was just esoteric nonsense! Didn't you? Didn't you?! (At least, my eyes glazed over whenever I used to read that section in the help... :)

Source.

 

So -- to combine that with deleting backwards to the last space -- you can use dvT<space>.

Granted, dvB, daW, diW, and vBd are faster and usually sufficient.