Vim删除多个单词

res*_*man 3 vim

之前我遇到的情况是我要删除3个单词,光标位于第一个单词内.例如

Vim是最好的文本编辑器

将光标放在hthe.我想结束

Vim是编辑

我尝试使用3diw来摆脱它们,但这让我失望了

Vim是文本编辑器

is和之间有2个空格text.3daw工作得很好,留给我我想要的东西,但我很困惑为什么3diw不工作.我本来期望3diw3daw删除相同数量的单词,并且唯一的区别是diw留下两个空格并daw留下一个.

那为什么3diw会有这种行为呢?

Ken*_*ent 10

你不明白之间的差别iwaw.使用[count]diw(内部单词),单词之间的空格也将被计算在内.但他们不会被计算在内aw

iw          "inner word", select [count] words (see |word|).
            White space between words is counted too.
            When used in Visual linewise mode "iw" switches to
            Visual characterwise mode.

                            *v_aW* *aW*
aW          "a WORD", select [count] WORDs (see |WORD|).
            Leading or trailing white space is included, but not
            counted.
Run Code Online (Sandbox Code Playgroud)

所以如果你想iw用你的例子,你需要按6diw:

1 the
2 " "
3 best
4 " "
5 text
6 " "
Run Code Online (Sandbox Code Playgroud)