Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uppercase vs lowercase word motion commands [duplicate]

Tags:

vim

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.

like image 602
user4418639 Avatar asked Jan 05 '15 02:01

user4418639


People also ask

What Vim command can you use to flip the case of a single letter lower case to upper case vice versa?

Switch case You can switch the case of the alpha character underneath your cursor in vi the tilde key ( ~ ). Doing so shifts from lowercase to uppercase and vice versa.

How do I uppercase a word in Vim?

Visual select the text, then U for uppercase or u for lowercase. To swap all casing in a visual selection, press ~ (tilde). Without using a visual selection, gU<motion> will make the characters in motion uppercase, or use gu<motion> for lowercase.


1 Answers

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.

like image 121
Gordonium Avatar answered Sep 23 '22 09:09

Gordonium