Difficulty: Easy
Correct Answer: R
Explanation:
Introduction / Context:
vi is a modal editor: normal mode for commands, insert mode for insertion, and replace mode for overwriting. Choosing the right command speeds up edits, especially when you need to overwrite existing text starting at the cursor position.
Given Data / Assumptions:
Concept / Approach:
Pressing uppercase R
enters replace mode. In this mode, each character you type overwrites the character under the cursor and then advances, effectively replacing text “to the right” until you exit the mode with Esc. This differs from single-character or line substitutions.
Step-by-Step Solution:
Position the cursor at the first character to overwrite.Press R to enter replace mode.Type the replacement text; existing characters are overwritten as you proceed.Press Esc to leave replace mode and return to normal mode.
Verification / Alternative check:
Try rX
to see that lowercase r replaces only one character with X. Compare with C
which changes (deletes) from the cursor to end-of-line and then enters insert mode, not replace mode.
Why Other Options Are Wrong:
r (Option A) replaces a single character only.s (Option C) deletes one character and enters insert mode (not continuous overwrite).S (Option D) substitutes the entire line (delete line, enter insert mode).
Common Pitfalls:
Final Answer:
R
Discussion & Comments