In the vi editor, which motion command moves the cursor backward to the beginning of the previous word segment?

Difficulty: Easy

Correct Answer: b

Explanation:


Introduction / Context:
Efficient navigation in vi/Vim relies on motion commands for word-wise movement. Knowing how to jump to the start or end of words without leaving normal mode dramatically speeds up editing tasks, especially for code and configuration files.


Given Data / Assumptions:

  • You are in normal mode in vi/Vim.
  • Words are defined according to the current setting (default word boundaries, not big-word motions).
  • You want to move backward to the beginning of a word.


Concept / Approach:

In vi, w moves forward to the start of the next word, e moves forward to the end of the current/next word, and b moves backward to the beginning of the previous word. Uppercase motions (e.g., W, E, B) treat whitespace-delimited WORDs. For the requested backward-to-beginning motion, b is correct.


Step-by-Step Solution:

Place the cursor somewhere inside or after a word.Press b to move to the beginning of the current/previous word.Use counts to repeat: 3b moves back three word boundaries.Combine with operators: dw deletes to the start of the next word; db deletes backward to the start of the previous word.


Verification / Alternative check:

Test with a sample line and compare behaviors of w, e, and b. Observe that only b navigates backward to the word start.


Why Other Options Are Wrong:

  • w: forward to next word start.
  • e: forward to word end.
  • a: enters insert mode after the cursor; not a motion.
  • None: incorrect because b is correct.


Common Pitfalls:

  • Confusing lowercase and uppercase motions (words vs WORDs).
  • Expecting a to navigate; it modifies text state.


Final Answer:

b.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion