Difficulty: Easy
Correct Answer: /pat
Explanation:
Introduction / Context:
Searching efficiently inside the vi (or Vim) editor is a core skill for developers and administrators. Vi supports forward and backward incremental searches using concise keystrokes, enabling rapid navigation through large configuration files, logs, and source code.
Given Data / Assumptions:
Concept / Approach:
In vi, forward search uses a slash followed by the pattern. Backward search uses a question mark. The colon prefix introduces ex-commands (for example, :w, :q, :%s/old/new/g) and is not used for plain search initiation. After a search, n and N repeat the search in the same or opposite direction respectively.
Step-by-Step Solution:
Verification / Alternative check:
Open a file containing multiple 'pat' occurrences; invoke /pat and confirm the cursor jumps forward to each occurrence with n. Reverse direction using N to validate the behavior.
Why Other Options Are Wrong:
Common Pitfalls:
Remaining in insert mode (press Esc first), forgetting that searches are case-sensitive unless 'ignorecase' or 'smartcase' is set, or leaving metacharacters unescaped when they are interpreted as regex tokens.
Final Answer:
/pat
Discussion & Comments