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
bjumps 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,
bmoves to the beginning of that word - If the cursor is already at the beginning of a word,
bjumps 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: f → b → q → T, landing on the first character of each preceding word.
Tips
- Use
wto move forward to the beginning of the next word - Use
eto move forward to the end of the current or next word - Use
geto 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.baris one WORD but two words) - Combine with operators:
dbdeletes backward to the start of the previous word,cbchanges backward to the start of the previous word - Use
3bto jump backward three words at once