Experiment 1
Open Vim, and insert only the following line of text in the buffer.
hello world
In other words, press i, type
hello world
and press Esc.Press 0 to position the cursor at the first character of first line.
- Press e. The cursor moves to
o
. - Press 0 to position the cursor at the first character of first line again.
Press de. You'll see that the characters from
h
too
have been deleted. Only the following text is left.world
Experiment 2
Open Vim, and insert only the following line of text in the buffer.
hello world
In other words, press i, type
hello world
and press Esc.Press 0 to position the cursor at the first character of first line.
- Press w. The cursor moves to
w
. - Press 0 to position the cursor at the first character of first line again.
Press dw. You'll see that the characters from
h
tohave been deleted. Only the following text is left.
world
However, I was expecting everything from
h
tow
to be deleted and only the following text to be left.orld
Question
First let me quote :help d
below.
*d*
["x]d{motion} Delete text that {motion} moves over [into register
x]. See below for exceptions.
In experiment 1, the motion due to e moved over from h
to o
and sure enough everything from h
to o
(including h
and o
) was deleted.
In experiment 2, the motion due to w moved over from h
to w
but everything from h
to w
(including h
and w
) was not deleted. Why?
The behaviour of dw, de, and db is summarized below.
Command Deletes character under the Deletes character under the
initial cursor position? final cursor position?
------- --------------------------- ---------------------------
dw Yes No
de Yes Yes
db No Yes
Why is the behaviour of the three commands inconsistent?