Reputation: 8512
I am using vim 7.3, installed through homebrew on OS X 10.8.3. For some reason neither W
or E
works as expected in normal mode. Rather than moving backward one word at a time, it moves forward. The behavior of W
is identical to w
. And the behavior of E
is identical to e
.
I have tried the o
and O
command in normal mode and it works as expected, so it is not like my shift key is broken.
This is driving me nuts because it is such core functionality that I can't get to work. I have tried erasing my vimrc and vim directory and change shell.
I will okay the answer of anybody who can either solve the problem for me or give good advice on how to diagnose the problem.
Upvotes: 3
Views: 1740
Reputation: 8408
w
means go forward to the start of a "word". In Vim, a "word" means:
\w+
), or[^\s\w]+
)W
means go forward to the start of a "WORD". In Vim, a "WORD" means:
\S+
)This example:
:help usr_03.txt
:
", "help
", "usr
", "_
", "03
", ".
", "txt
":help
", "usr_03.txt
" e
, E
, b
, B
works in a similar manner.
Not directly related to the question, but if you want to find what a key (or key combination) does, simply use
:h {key}
Note: casing matters.
Examples:
:h W
:h w
:h yy
:h CTRL-W_T
or the shorthand ^W_T
Upvotes: 0
Reputation: 4006
W
and E
are not the backward-versions of w
and e
(b
and ge
are, respectively).
Lowercase versions consider words to stop at non-word characters such as punctuation or whitespace. Uppercase versions only consider whitespace (therefore moving past words with punctuation in them). The vim manual explains all combinations clearly:
ge b w e
<- <- ---> --->
This is-a line, with special/separated/words (and some more).
<----- <----- --------------------> ----->
gE B W E
You can find this overview in Getting Started under Moving Around (:help usr_03.txt
), and more details at :help word-motions
.
Upvotes: 15
Reputation: 17537
The functionality you described is not standard Vim, but if you're used to it, try these mappings:
nnoremap W B
nnoremap E gE
Upvotes: 0
Reputation: 15693
shift+W does not usually work backwards. It moves forwards like w, just with a different definition of "word" (e.g. W will skip over "hello-world", w will end up at the hyphen).
Moving backwards is b.
Please use the vim help (:h W
in this instance) before thinking something is broken.
Upvotes: 10