16

Is there any difference between W, E, B and w, e and b?

The game vim adventures has you pick up an uppercase B in order to skip over a rock on an exclamation point, i.e.:

Remember: 
wordsXare
not WORDSX!

The two 'X's represent a treasure chest and rock respectively. In order to skip over the rock, one has to use the uppercase B rather than the lowercase b. Then in usr_03.txt, section 03.1, it talks about the uppercase word motion commands.

   It is also possible to move by white-space separated WORDs.  This is not a
word in the normal sense, that's why the uppercase is used.  The commands for
moving by WORDs are also uppercase, as this figure shows:

           ge      b      w             e
           <-     <-   --->                   --->
    This is-a line, with special/separated/words (and some more). ~
       <----- <-----   -------------------->          ----->
         gE      B           W           E

With this mix of lowercase and uppercase commands, you can quickly move
forward and backward through a paragraph.

But when I do the :help W command, it gives me this:

4. Word motions                        word-motions

   or                  <S-Right> w
w           [count] words forward.  |exclusive| motion.

   or                  <C-Right> W
W           [count] WORDS forward.  |exclusive| motion.

There doesn't seem to be any difference. I'm using Vim 7.4.

user4418639
  • 161
  • 1
  • 3

1 Answers1

34

This basically comes down to what vi considers to be a 'word'.

Here's a piece of text but navigated using uppercase W,B etc:

enter image description here

and here's the same text navigated using lowercase w,b etc:

enter image description here

Basically a 'WORD' is surrounded by whitespace whereas a 'word' can be surrounded and include certain characters such as - or ' etc.

Gordonium
  • 3,389
  • 23
  • 39