【问题标题】:What's the difference between de and dw in vim?vim中的de和dw有什么区别?
【发布时间】:2014-10-03 07:10:55
【问题描述】:

按照vimtutor 的提示,我在第 2.3 课中发现了以下内容:

Many commands that text are made from an operator and a motion.
The format for a  follows:

      d   motion

Where:
  d      - is the delete operator.
  motion - is what the operator will operate on (listed below).

A short list of motions:
  w - until the start of the next word, EXCLUDING its first character.
  e - to the end of the current word, INCLUDING the last character.
  $ - to the end of the line, INCLUDING the last character.

但是,我看不出 dwde 之间的区别。使用dwde的用例是什么?

【问题讨论】:

  • 经期如何处理?

标签: vim keyboard-shortcuts


【解决方案1】:

dw 表示“从这里切到下一个单词”。

before: fo[o]bar baz
        dw
after:  fo[b]az

de 表示“从这里切到当前单词的结尾”。

before: fo[o]bar baz
        de
after:  fo[ ]baz

【讨论】:

    【解决方案2】:

    有这样的缓冲区:

    Lorem ipsum dolor
    

    将光标()移动到ipsum字的中间:

    Lorem ip▒um dolor
    

    现在按 de

    Lorem ip▒dolor
    

    光标从当前单词中删除了字母,直到结尾,但没有空格。

    在做dw的时候会删除空格:

    Lorem ip▒olor
    

    【讨论】:

      猜你喜欢
      • 2017-05-31
      • 2011-07-22
      • 1970-01-01
      • 2019-02-23
      • 2014-08-13
      • 2010-09-09
      • 1970-01-01
      • 2015-12-10
      • 2017-06-05
      相关资源
      最近更新 更多