What's the difference between de and dw in vim?

Following the advice vimtutor

, I found the following in lesson 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.

      

However, I don't see any difference between d wand d e. What is used in the use case d wand d e?

+3


source to share


2 answers


Having a buffer like this:

Lorem ipsum dolor

      

Move the cursor (

) in the middle of a word ipsum

:

Lorem ip▒um dolor

      

Now press d e:



Lorem ip▒dolor

      

The cursor has deleted letters from the current word to the end, but without a space.

When executed, the d wspace will be removed:

Lorem ip▒olor

      

+6


source


dw

means "cut from here to the next word."

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

      



de

means "cut from here to the end of the current word".

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

      

+3


source







All Articles