vi/vim navigation — moving the cursor left In the classic vi (and vim in normal mode), which single-key motion command moves the cursor one character to the left?

Difficulty: Easy

Correct Answer: h

Explanation:


Introduction / Context:
Efficient text editing in Unix-like systems often relies on the vi/vim editor. Mastering the basic motion keys lets you navigate without leaving the home row. This question checks your knowledge of the fundamental h-j-k-l navigation pattern used to move the cursor left, down, up, and right in normal mode.



Given Data / Assumptions:

  • The editor is vi or vim operating in normal (command) mode, not insert or visual mode.
  • We are using default key bindings (no remapping).
  • The task is to move exactly one character position to the left.


Concept / Approach:

vi was designed for terminals without arrows. The navigation keys were placed under the right hand: h (left), j (down), k (up), l (right). Movement commands act once per keystroke but can be repeated with a numeric count. They do not insert text; they reposition the cursor only.



Step-by-Step Solution:

Ensure you are in normal mode by pressing Esc.Use h to move left by one character.Optionally, prefix with a count (for example, 5h moves left five characters).Remember the full set: h=left, j=down, k=up, l=right.


Verification / Alternative check:

Open any file, place the cursor in the middle of a word, press h repeatedly, and observe the cursor shift left. Compare with l (right) and j/k (vertical movement) to reinforce the mapping.



Why Other Options Are Wrong:

  • i: enters insert mode; it does not move left.
  • j: moves the cursor down one line.
  • k: moves the cursor up one line.
  • None of the above: incorrect because h is correct.


Common Pitfalls:

Forgetting to leave insert mode before attempting movement; assuming arrow keys are required; holding the key continuously instead of using counts for faster movement; remappings that change defaults in personal configs.


Final Answer:

h

More Questions from Unix

Discussion & Comments

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