代码之家  ›  专栏  ›  技术社区  ›  resueman

Vim删除多个单词

vim
  •  4
  • resueman  · 技术社区  · 10 年前

    早些时候,我想删除3个单词,光标位于第一个单词的内部。例如

    Vim是最好的文本编辑器

    光标位于 h 在里面 the 。我想在

    Vim是编辑器

    我试着用3diw来清除它们,但这让我

    Vim是文本编辑器

    中间有2个空格 is text . 3daw 工作很好,给我留下了我想要的东西,但我很困惑为什么 3diw 不起作用。我早就料到了 3天 3道 删除相同数量的单词,唯一的区别是 diw 留下两个空格和 daw 留下一个。

    那么为什么 3天 有这种行为吗?

    1 回复  |  直到 10 年前
        1
  •  12
  •   Kent    10 年前

    你不明白两者之间的区别 iw aw 具有 [count]diw (内部单词),单词之间的空格也会被计算在内。但他们不会被计算在内

    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.
    

    所以如果你想 国际工作组 举你的例子,你需要压力 6diw :

    1 the
    2 " "
    3 best
    4 " "
    5 text
    6 " "