早些时候,我想删除 3 个单词,光标在第一个单词内。例如
Vim is the best text editor
将光标放在
h
中的 the
上。我想结束在Vim is editor
我尝试使用 3diw 来摆脱它们,但这给我留下了
Vim is text editor
is
和 text
之间有 2 个空格。 3daw
工作正常,给我留下了我想要的东西,但我很困惑为什么 3diw
不起作用。我本来希望 3diw
和 3daw
删除相同数量的单词,唯一的区别是 diw
留两个空格而 daw
留一个。那么为什么
3diw
有这种行为呢?
最佳答案
你不明白 iw
和 aw
之间的区别。使用 [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.
因此,如果您想在示例中使用
iw
,则需要按 6diw
:1 the
2 " "
3 best
4 " "
5 text
6 " "
关于Vim 删除多个单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25229562/