Word Motions


We previously learned about text objects, and more specifically about Vim's definitions for words and words. In this section we will learn another way to move horizontally within a buffer, using motions than move the cursor across one or more words.

CommandAction
wcursor N words forward
Wcursor N WORDS forward
ecursor forward to the end of word N
Ecursor forward to the end of WORD N
bcursor N words backward
Bcursor N WORDS backward
gego backwards to the end of the previous word
gEgo backwards to the end of the previous WORD

Let's first look at how w behaves with the first line of text:

Initial Conditions
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:1
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:6
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:9
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:11
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:16
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:21
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:28
 
Move the cursor (again)w
This·is·a·line·with·sample·text. 
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:32
 
Move the cursor (again)w
This·is·a·line·with·sample·text. 
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:1
 

Now, let's look at how W behaves with the same text:

Initial Conditions
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:1
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:6
 
Move the cursor (again)W
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:9
 
Move the cursor (again)W
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:11
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:16
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:21
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMALTop1:28
 
Move the cursor (again)W
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:1
 

w and W behave almost the same for this text. The only difference is the way the trailing period is handled. w stops at the period in step 7, while W steps over the period and proceeds to the next line.

Now, lets look at w with the second line of text:

Initial Conditions
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:1
 
Move the cursor (again)w
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:6
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:11
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:15
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:21
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:26
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:27
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:33
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:36
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:42
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:43
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:47
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:52
 
Move the cursorw
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL50%3:1
 

And again, with W

Initial Conditions
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:1
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:6
 
Move the cursor (again)W
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:11
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:15
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:21
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:33
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:36
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:42
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL33%2:47
 
Move the cursorW
This·is·a·line·with·sample·text.
This·line·has·other·types/kinds·of·words·(and·WORDS)!
 
This·is·a·new·paragraph.·This·is·another·sentence.
And·this·is·another·line.
NORMAL50%3:1
 

The differences between how w and W behave are highlighted in this text.