How to move one word left in the vi editor

VimVi

Vim Problem Overview


I use the shortcut w to move the cursor one word right. Is there a shortcut to move a word left?

Vim Solutions


Solution 1 - Vim

Use b to move back one word.

Use w to move forward one word.

And here is a cheat sheet that might be useful for you:

Alt text

Source: Graphical vi-vim Cheat Sheet and Tutorial

Solution 2 - Vim

It's b.

You can see other motions here:

Vim documentation: motion, 4. Word motions

Generally a Vim command consists of:

count action motion

Where:

count is number of times you want it to execute. The default is 1.

action is obviously an action: d for delete, c for change, default is empty, and it means simply move.

motion is the direction. You got that already.

Solution 3 - Vim

In addition to the b movement mentioned in the other answers, another movement which may be interesting is ge.

It brings you to the last letter of the word on the left. When b is considered as the opposite of w, ge can be considered as the opposite of e which brings you to the end of the current word.

Also note that all of those word-wise movement have a WORD-wise equivalent: W, B, E and gE which are "faster". For the difference between words and WORDS see: :h word.

Solution 4 - Vim

Yes, you can use "b" to backforward a word, and in advance, "2b" to move back two words.

Solution 5 - Vim

You want to move left (back). b does it.

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
QuestionSureshView Question on Stackoverflow
Solution 1 - VimWazeryView Answer on Stackoverflow
Solution 2 - VimGoran JovicView Answer on Stackoverflow
Solution 3 - VimstatoxView Answer on Stackoverflow
Solution 4 - VimJimmy HuangView Answer on Stackoverflow
Solution 5 - VimkhachikView Answer on Stackoverflow