When you're using vim, you can move forward word by word with w
. How do I go backwards?

- 7,845
- 6
- 49
- 72
-
9http://www.viemu.com/vi-vim-cheat-sheet.gif This has a lot of the vim keys in an easy graphical format. I highly recommend printing it and having it next to your computer if you are going to be using vim a lot. – Sam Brinck Feb 09 '12 at 15:39
-
possible duplicate of [How to move one word left in vi editor](http://stackoverflow.com/questions/4488979/how-to-move-one-word-left-in-vi-editor) – Arslan Ali Jul 07 '15 at 12:11
-
1Also see: http://stackoverflow.com/questions/5125270/in-vim-vi-how-do-you-move-the-cursor-to-the-end-of-the-previous-word if interested in going backwards to the end of previous word - using ge and gE – arcseldon Jan 19 '16 at 08:19
4 Answers
Use b
to go back a word.
You may also want to check out W
and B
to advance/go back a WORD
(which
consists of a sequence of non-blank characters separated with white space, according to :h WORD
).
-
60For completeness sake `ge` will go backward to the end of a word. `gE` will go backward to the end of a `WORD` – Peter Rincker Feb 09 '12 at 21:24
-
5
-
3What's the difference between b and B? Or w and W? Behavior seems the same. – Casey Patton Oct 11 '13 at 19:48
-
1@CaseyPatton: The uppercase versions treat any sequence of non-whitespace as words; lowercase is similar to `\w|\S`. See `:help word` and `:help WORD` for more details. – rninty Dec 12 '13 at 19:40
-
Also worth considering ge and gE for going backwards to the end of the previous word. Also, see http://stackoverflow.com/questions/5125270/in-vim-vi-how-do-you-move-the-cursor-to-the-end-of-the-previous-word – arcseldon Jan 19 '16 at 08:18
-
1
It helps for me to think of it as:
b
to go to beginning of current or previous word
w
to go the beginning of next word
e
to go to the end of current or next word
ge
to go the end of the previous word
Try :h word-motions
for more details and how to combine them with operations.

- 35,523
- 17
- 121
- 125

- 3,183
- 1
- 23
- 26
Alternatively, if you use w
, b
, W
, and B
to navigate lines by hopping over words, consider the following alternatives which can be faster if used correctly.
f<char> # jump to next occurrence of <char> to right (inclusive)
or
F<char> # jump back to next occurrence of <char> to left (inclusive)
If your words are separated by spaces
If your words are separated by <space>
you can hop over words by spaces:
f<space>;;;;
where ;
repeats the previous command, so you hop forward by spaces
F<space>;;
to hop backwards by space
If your words are separated by punctuation and not spaces
just replace <char>
with punctuation, for example .
The punctuation method is not efficient for scrolling through, but if you know where you want to jump, it can usually get there in a jump or two.

- 32,039
- 22
- 142
- 171

- 490
- 4
- 11