More Questions from Unix

In the vi editor, which single-key motion command moves the cursor forward to the next paragraph boundary (that is, to the end of the current paragraph / start of the next)?

Computer Science Unix Difficulty: Easy
Choose an option
  • A
    }
  • B
    {
  • C
    $
  • D
    |
  • E
    None of the above

Answer

Correct Answer: }

Explanation

Introduction / Context:Efficient navigation in vi relies on motion commands for words, sentences, and paragraphs. Paragraph motions are especially useful when editing prose, documentation, or code comments separated by blank lines or section macros.

Given Data / Assumptions:

  • Paragraphs are delimited by blank lines or defined macros (per vi settings).
  • You want to move from within a paragraph to its boundary efficiently.
  • Standard vi keybindings are assumed.

Concept / Approach:In vi, '}' advances the cursor to the next paragraph boundary, effectively moving you past the end of the current paragraph and onto the first non-blank line of the next block. The inverse motion '{' moves to the previous paragraph boundary. Other motions like '$' and '|' operate within the current line only and do not consider paragraph structures.

Step-by-Step Solution:

Place the cursor anywhere in a paragraph.Press } to jump to the next paragraph boundary.Use { to move backward to the previous paragraph boundary.Combine with operators (for example, d}) to act on text until the next boundary.

Verification / Alternative check:Test in a file with multiple blank-line-separated paragraphs. Press } repeatedly to step through paragraphs. Confirm that '$' only moves to end-of-line and does not change paragraphs.

Why Other Options Are Wrong:

  • {: Moves to the previous paragraph, not forward.
  • $: Moves to the end of the current line only.
  • |: Moves to a given column on the current line.
  • None of the above: Incorrect because '}' is correct.

Common Pitfalls:Misconfigured paragraph macros or unusual file formatting may alter boundary detection; ensure blank lines or proper macros exist for predictable movement.

Final Answer:}

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