【问题标题】:Vim deleting multiple wordsVim 删除多个单词
【发布时间】:2014-08-10 22:48:19
【问题描述】:

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

Vim 是最好的文本编辑器

将光标放在the 中的h 上。我想结束在

Vim 是编辑器

我尝试使用 3diw 来摆脱它们,但这让我没有

Vim 是文本编辑器

istext 之间有 2 个空格。 3daw 工作得很好,给我留下了我想要的东西,但我对为什么 3diw 不起作用感到困惑。我本来希望3diw3daw 删除相同数量的单词,唯一的区别是diw 留两个空格,daw 留一个。

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

【问题讨论】:

    标签: vim


    【解决方案1】:

    您不了解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.
    

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

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

    【讨论】:

    • 啊,谢谢。我没有意识到内部空间会被视为单词。
    猜你喜欢
    • 1970-01-01
    • 2012-07-24
    • 2011-10-14
    • 1970-01-01
    • 2015-06-11
    • 2014-12-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-06
    相关资源
    最近更新 更多