Difficulty: Easy
Correct Answer: to move the cursor to a matching delimiter (parenthesis, bracket, or brace)
Explanation:
Introduction / Context:
Efficient navigation in vi (and Vim) includes quickly jumping between paired delimiters. This is invaluable when editing source code that contains nested parentheses (), brackets [], and braces {}. The percent key provides a direct way to verify structural balance and traverse matching pairs.
Given Data / Assumptions:
Concept / Approach:
Pressing '%' moves the cursor to the matching partner of the delimiter under the cursor. This works for (), [], and {} and respects nesting. If the cursor is not on a delimiter, vi searches forward on the line for one before attempting a match. This simple motion helps you inspect block boundaries, function scopes, and array indices rapidly.
Step-by-Step Solution:
Verification / Alternative check:
In a function with nested blocks, press % at different levels and confirm that vi selects the correct matching partner each time, reflecting proper nesting logic.
Why Other Options Are Wrong:
Common Pitfalls:
Pressing % when the cursor is not on a delimiter (it may not jump as expected) or relying on % when delimiters are unbalanced, which can confuse navigation.
Final Answer:
to move the cursor to a matching delimiter (parenthesis, bracket, or brace)
Discussion & Comments