实验1
>打开Vim,并在缓冲区中只插入以下一行文本。
- hello world
换句话说,按i,键入hello world并按Esc。
>按0将光标定位在第一行的第一个字符。
>按e。光标移动到o。
>按0将光标重新定位在第一行的第一个字符处。
>按de。您将看到从h到o的字符已删除。只剩下下面的文本。
- world
实验2
>打开Vim,并在缓冲区中只插入以下一行文本。
- hello world
换句话说,按i,键入hello world并按Esc。
>按0将光标定位在第一行的第一个字符。
>按w。光标移动到w。
>按0将光标重新定位在第一行的第一个字符处。
>按dw。你会看到从h到的字符已被删除。只剩下下面的文本。
- world
然而,我期待从h到w的一切都被删除,只剩下下面的文本。
- orld
题
首先让我引用:help d下面。
- *d*
- ["x]d{motion} Delete text that {motion} moves over [into register
- x]. See below for exceptions.
在实验1中,由于从h移动到o并且确保从h到o(包括h和o)的足够的一切的运动被删除。
在实验2中,由于w从w移动到w,但是从h到w(包括h和w)的一切都不被删除。为什么?
dw,de和db的行为总结如下。
- Command Deletes character under the Deletes character under the
- initial cursor position? final cursor position?
- ------- --------------------------- ---------------------------
- dw Yes No
- de Yes Yes
- db No Yes
为什么三个命令的行为不一致?