【问题标题】:Vim actions like "da" that don't remove whitespace像 "da" 这样不删除空格的 Vim 操作
【发布时间】:2015-01-16 16:23:33
【问题描述】:

我有一些这样的文字:

foo<space><space><space>'bar'

当我在'bar' 中执行da' 时,空格被删除:

foo

我怎样才能在不删除空格的情况下执行da',所以我得到了这个结果?

foo<space><space><space>

【问题讨论】:

    标签: vim


    【解决方案1】:

    我在text-objects 的 vim 帮助主题中找到了这个:

    i"                          *v_iquote* *iquote*
    i'                          *v_i'* *i'*
    i`                          *v_i`* *i`*
                Like a", a' and a`, but exclude the quotes and
                repeating won't extend the Visual selection.
                Special case: With a count of 2 the quotes are
                included, but no extra white space as with a"/a'/a`.
    

    因此,执行以下操作不会删除空格。

    d2i'
    

    有关文本对象的更多帮助,请:help text-objects

    【讨论】:

      【解决方案2】:

      :help v_i':

      对此进行了介绍

      对于“a”命令:运算符适用于对象和白色 对象后的空间。如果对象后面没有空格 或者当光标在对象之前的空白处时,白色 包含对象之前的空格。

      所以,问题在于您排在最后。要更改行为,您可以添加一个空格,返回,然后发出命令:A&lt;Space&gt;&lt;Esc&gt;hda'

      或者,使用 inner 对象,然后删除两个引号,如di'hxx

      对于引用文本对象,甚至还有一个方便的特殊情况,所以 d2i' 看起来像赢家

        Special case: With a count of 2 the quotes are
        included, but no extra white space as with a"/a'/a`.
      

      【讨论】:

        猜你喜欢
        • 2016-01-27
        • 1970-01-01
        • 2010-10-16
        • 2011-10-21
        • 1970-01-01
        • 1970-01-01
        • 2023-03-21
        • 2010-09-26
        • 1970-01-01
        相关资源
        最近更新 更多