如果你经常使用 dw 和 de,你会发现两者的表现不太一致,另外 db 并不能删除当前光标所在处的字符,很蛋疼,为什么是这样呢?原来和 Vim 中一个动作的 exclusivity 有关。
认真学习了一下,写了一篇短文: https://jdhao.github.io/2019/05/18/nvim_exclusive_inclusive_motion/
不知道有多少人不知道的,欢迎讨论。。
|  |      1vitovan      2019-05-18 08:28:13 +08:00 via Android 学习了,虽然没看太明白,VIM 太难了 | 
|      3carlclone      2019-05-18 08:55:01 +08:00 via Android 通常使用 ciw 删除和修改 | 
|  |      4conanforever22      2019-05-18 08:58:47 +08:00  1 学习了,  平时用 df{char} / dt{char} , 看 help 发现 f{char}/t{char}都是 inclusive, 加了 v 可以转换为 exclusive | 
|  |      5thedrwu      2019-05-18 09:03:05 +08:00 via Android 手指对着空气比划了一下才想起来 dw 和 de 有什么区别。 跟形码输入汉字一样,成为了肌肉记忆之后看着字母不知道它要干什么。。 | 
|  |      6jdhao OP @conanforever22 自带的 f 只能找一个字符,不精确,我用 vim-sneak 代替,可以找两个字符,精确度大大提升,基本上三个按键跳到眼睛能看到的任何地方 | 
|      7shaco      2019-05-18 09:17:19 +08:00  1 @jdhao #2 为啥我觉得 de 才是 exclusive,dw 才是 inclusive。因为根据这两个单词的意思,exclusive 的意思应该是把最后一个字符排除在外,也就是不删除最后一个字符。而 inclusive 应该是删除最后一个字符 | 
|  |      8jdhao OP  1 @shaco 你还没理解正确,以 de 为例,e 跳到 hello 的 o 处,因为 e 是 inclusive,所以从 h 到 o 的所有字符都被删除了,如果 e 是 exclusive,那么字符 o 不会被删除 | 
|  |      9vitovan      2019-05-18 10:09:31 +08:00 via Android  1 @shaco  @jdhao 我把这个贴到这里,可能会帮助理解: ``` Many commands that text are made from an operator and a motion. The format for a follows: d motion Where: d - is the delete operator. motion - is what the operator will operate on (listed below). A short list of motions: w - until the start of the next word, EXCLUDING its first character. e - to the end of the current word, INCLUDING the last character. $ - to the end of the line, INCLUDING the last character. ``` | 
|  |      10vitovan      2019-05-18 10:11:25 +08:00 via Android 然后,我想我理解了,谢谢楼主。 | 
|  |      12mrvon      2019-05-18 11:07:50 +08:00 仔细一想, dw, de 两个命令中,w, e 两个 motion 与 d 结合之后,行为不一致了。为了适应使用者的直觉,所以搞了 exclusive 和 inclusive。感谢分享。 | 
|  |      13mrcode      2019-05-18 15:13:52 +08:00 一般习惯用 df* 和 dt* | 
|  |      14jciba5n4y6u      2019-05-18 21:31:43 +08:00 dw 经常用,de 没用过。 |