In the vi (Vim) editor, which single-key Normal-mode command deletes exactly one character at the cursor position?

Difficulty: Easy

Correct Answer: x

Explanation:


Introduction / Context:
Mastering vi/Vim involves knowing concise Normal-mode commands for quick edits. Deleting a single character without entering Insert mode is a frequent operation when fixing typos or cleaning code, and there is a dedicated key for it.


Given Data / Assumptions:

  • You are in Normal mode (press Esc to ensure you are not inserting).
  • The cursor is on the character to be deleted.
  • You want to remove exactly one character without affecting surrounding text.


Concept / Approach:
The 'x' command deletes the character under the cursor. It can be prefixed by a count to delete multiple characters (for example, '3x' deletes three characters). Related commands include 'X' to delete the character to the left and 's' to substitute the character by entering Insert mode after deletion.


Step-by-Step Solution:

Press Esc to be in Normal mode.Place the cursor on the character to remove.Press x to delete that single character.Optionally repeat or use a count like 5x for five characters.


Verification / Alternative check:
Undo with 'u' to confirm exactly one character was affected. Compare with 'dl' (delete right), which achieves a similar effect; both operate at character granularity but 'x' is the canonical shortcut.


Why Other Options Are Wrong:

  • y: Yank (copy) text; it does not delete.
  • a: Append after the cursor and enter Insert mode; no deletion.
  • z: Scroll/center line operations; not deletion.
  • None of the above: Incorrect because 'x' is correct.


Common Pitfalls:
Remaining in Insert mode and pressing 'x' results in literal typing of 'x'. Always ensure Normal mode before issuing motion/edit commands.


Final Answer:
x

Discussion & Comments

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