vi/vim editor — overstriking text on a whole line (Replace mode) In the classic vi editor (command mode), which single key starts Replace mode so that your typing overwrites existing text (useful when you want to overstrike an entire line from the cursor onward)?

Difficulty: Easy

Correct Answer: R

Explanation:


Introduction / Context:
vi and its modern descendant vim provide several modes. Knowing how to enter Replace mode allows you to overstrike existing text instead of inserting and shifting it. This is handy when you want to overwrite a whole line quickly from the cursor position.



Given Data / Assumptions:

  • Editor is classic vi/vim in command (normal) mode.
  • We want to overstrike characters rather than insert new ones.
  • We need the single-key command to begin Replace mode.


Concept / Approach:

In vi, pressing R enters Replace mode. Characters you type overwrite existing characters until you press Escape to return to normal mode. This differs from lowercase r, which replaces only a single character. Other keys like u (undo), v (visual mode), and C (change to end of line) serve different purposes and do not perform continuous overstrike.



Step-by-Step Solution:

Position the cursor at the start of the line (e.g., using 0) or where overstriking should begin.Press R to enter Replace mode; notice the status indicator in vim.Type the new content; each keystroke overwrites existing characters.Press Esc to exit Replace mode when finished.


Verification / Alternative check:

Experiment in a test file: type some text, press R, then type a different phrase of the same or longer length. You will see characters overwritten rather than inserted; if longer, following text is overwritten as you continue.



Why Other Options Are Wrong:

  • v: enters Visual mode to select text; does not overstrike.
  • C: “change to end of line” (equivalent to c$), which deletes then enters insert mode, not overstrike.
  • u: undo last change.
  • None of the above: incorrect because R is correct.


Common Pitfalls:

Confusing R with r (single-character replace); attempting to overstrike in Insert mode; forgetting to press Esc to leave Replace mode before running other commands.


Final Answer:

R

More Questions from Unix

Discussion & Comments

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