Vim lessons
Practice
Advanced
10 min
Search Navigation Mastery
Task Instructions
Become an expert at finding and navigating search results
Practice searching through code. Use /error to search forward for 'error', then use n to go to next match and N for previous match. Try ?error for backward search.
Learning objectives
- Master forward and backward search
- Perfect search result navigation
- Learn search patterns and options
Required keystrokes
Your submission is checked for these keystrokes, not just the final text — so reach for the technique, not a workaround.
- / Use forward search
- n Navigate to next match
Helpful commands
- /pattern
- Search forward for pattern
- ?pattern
- Search backward for pattern
- n
- Go to next search match
- N
- Go to previous search match
- *
- Search for word under cursor
- #
- Search backward for word under cursor
Stuck? Peek at a hint 3 hints · try it on your own first
- / searches forward, ? searches backward
- n = next match in same direction, N = next match in opposite direction
- Add \c for case-insensitive search: /error\c
// JavaScript Error Handler
function handleError(error) {
if (error instanceof TypeError) {
console.error('Type error occurred:', error);
logError(error, 'TYPE_ERROR');
} else if (error instanceof ReferenceError) {
console.error('Reference error found:', error);
logError(error, 'REFERENCE_ERROR');
} else if (error instanceof SyntaxError) {
console.error('Syntax error detected:', error);
logError(error, 'SYNTAX_ERROR');
} else {
console.error('Unknown error:', error);
logError(error, 'UNKNOWN_ERROR');
}
// Send error report
if (shouldReportError(error)) {
reportError(error);
}
}
function logError(error, type) {
const timestamp = new Date().toISOString();
const errorLog = {
timestamp,
type,
message: error.message,
stack: error.stack
};
// Store error in database
database.errors.insert(errorLog);
}
Search for 'error' (forward and backward), practice with n and N.