In Vim, I'd like to go back a word. The opposite of `w`

Vim

Vim Problem Overview


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

Vim Solutions


Solution 1 - Vim

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).

Solution 2 - Vim

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.

Solution 3 - Vim

use "b" to move back - just tested in vi - works fine.

Solution 4 - Vim

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjoslinmView Question on Stackoverflow
Solution 1 - VimgefeiView Answer on Stackoverflow
Solution 2 - VimSteve McKinneyView Answer on Stackoverflow
Solution 3 - VimFreudianSlipView Answer on Stackoverflow
Solution 4 - Vimbrother-biloView Answer on Stackoverflow