vi editor navigation: In classic vi normal mode, which single-key motion command moves the cursor one character to the left?

Difficulty: Easy

Correct Answer: h

Explanation:


Introduction / Context:
vi and Vim provide powerful keyboard-centric navigation. The four basic motion keys h, j, k, and l allow cursor movement without leaving the home row. Mastering these motions improves speed and precision during text editing on UNIX systems.



Given Data / Assumptions:

  • You are in normal mode (not insert mode) in vi/Vim.
  • You want to move exactly one character left.
  • No multi-count prefix is used (like 5h).


Concept / Approach:

vi normal mode maps movement keys to directions: h (left), j (down), k (up), l (right). These motions can be combined with numeric counts and with operators (such as d for delete) to form powerful editing commands (for example, dh deletes one character to the left).



Step-by-Step Solution:

Ensure you are in normal mode by pressing Escape.Press h to move one character to the left.Use a count, such as 5h, to move five characters left.Combine with operators: dh deletes left, yh yanks left, ch changes left.Use l, j, k for the other directions to navigate efficiently.


Verification / Alternative check:

Observe the cursor position before and after pressing h. Compare with arrow keys if enabled; in minimal terminals, hjkl remain reliable even without arrow key support.



Why Other Options Are Wrong:

b: k moves the cursor up one line.

c: j moves the cursor down one line.

d: i switches to insert mode at the cursor; it does not move left.

e: Not applicable because h is the correct motion for one character left.



Common Pitfalls:

Accidentally being in insert mode (where h inserts a character) and forgetting motion counts. Practice keeps motions fluid and reduces reliance on arrow keys.



Final Answer:

h

Discussion & Comments

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