joslinm
joslinm

Reputation: 8105

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

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

Upvotes: 269

Views: 85232

Answers (4)

brother-bilo
brother-bilo

Reputation: 610

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.

Upvotes: 10

gefei
gefei

Reputation: 19776

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

Upvotes: 357

Steve McKinney
Steve McKinney

Reputation: 3361

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.

Upvotes: 112

FreudianSlip
FreudianSlip

Reputation: 2920

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

Upvotes: 11

Related Questions