vimtricks.wiki Concise Vim tricks, one at a time.

How do I jump to the beginning of the previous word?

Answer

b

Explanation

The b command moves the cursor backward to the beginning of the previous word. It is one of Vim's fundamental word motions and the counterpart to w, which moves forward.

How it works

  • b jumps backward to the start of the previous word
  • A "word" in Vim is a sequence of letters, digits, and underscores, or a sequence of other non-blank characters
  • If the cursor is in the middle of a word, b moves to the beginning of that word
  • If the cursor is already at the beginning of a word, b jumps to the beginning of the word before it

Example

Given the text with the cursor on the f of fox:

The quick brown fox

Pressing b three times moves the cursor: fbqT, landing on the first character of each preceding word.

Tips

  • Use w to move forward to the beginning of the next word
  • Use e to move forward to the end of the current or next word
  • Use ge to move backward to the end of the previous word
  • Use B (uppercase) to move backward by WORD — whitespace-delimited chunks that treat punctuation as part of the word (e.g., foo.bar is one WORD but two words)
  • Combine with operators: db deletes backward to the start of the previous word, cb changes backward to the start of the previous word
  • Use 3b to jump backward three words at once

Next

How do I edit multiple lines at once using multiple cursors in Vim?