How do I search for files in Visual Studio Code?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Press Ctrl+P (Windows/Linux) or Cmd+P (Mac) to search for files by name in VS Code. This opens Quick Open, which does fuzzy matching across every file in your workspace. For searching text inside files, use Ctrl+Shift+F / Cmd+Shift+F. These two shortcuts cover 90% of what you need, and this article covers everything else.
Quick Open: Search by File Name
Quick Open (Ctrl+P / Cmd+P) is the fastest way to jump to any file in your project.
How it works
- Press the shortcut
- Start typing any part of the file name
- Select from the filtered list and press
Enter
Quick Open uses fuzzy matching, meaning you do not need to type the exact file name. Typing usrctrl matches UserController.ts. Typing pkgjsn matches package.json.
Power features in Quick Open
Quick Open supports special prefixes that change its behavior:
| Prefix | Behavior | Example |
| (none) | File search | UserService |
> | Command Palette | >format document |
@ | Go to symbol in file | @handleSubmit |
@: | Go to symbol by category | @:function |
# | Go to symbol in workspace | #UserModel |
: | Go to line number | :42 |
You can chain these. Opening Quick Open and typing UserService.ts:25 opens that file at line 25.
Recently opened files
Quick Open shows recently opened files at the top of the list, even before you type anything. This makes it a fast file switcher. Press Ctrl+P twice quickly to cycle through recent files (similar to Alt+Tab behavior).
Search Across Files: Find in Workspace
For searching text inside files, use Ctrl+Shift+F / Cmd+Shift+F. This opens the Search panel in the sidebar.
Basic text search
- Press
Ctrl+Shift+F/Cmd+Shift+F - Type the text you are looking for
- Results appear grouped by file, with line previews
Search options (the toggle buttons)
The search bar has three toggle buttons:
| Button | Shortcut | Effect |
Aa | Alt+C | Case-sensitive matching |
Ab | Alt+W | Match whole word only |
.* | Alt+R | Use regular expressions |
Include and exclude patterns
Below the search box, click the ellipsis (...) or press Ctrl+Shift+J / Cmd+Shift+J to reveal the files to include and files to exclude fields.
Glob patterns work here:
| Pattern | Matches |
*.ts | All TypeScript files |
src/**/*.ts | TypeScript files inside src/ |
!**/node_modules | Exclude node_modules |
*.{ts,tsx} | TypeScript and TSX files |
Replace across files
The search panel also supports find-and-replace across your entire workspace:
- Press
Ctrl+Shift+H/Cmd+Shift+H(or expand the replace field in search) - Enter the search term and replacement
- Preview changes, then click the replace icon next to individual results or "Replace All"
VS Code shows a diff preview before applying replacements, so you can review each change.
Search Within a Single File
For searching inside the currently open file:
| Shortcut | Action |
Ctrl+F / Cmd+F | Find in current file |
Ctrl+H / Cmd+H | Find and replace in current file |
F3 / Cmd+G | Jump to next match |
Shift+F3 / Cmd+Shift+G | Jump to previous match |
Ctrl+D / Cmd+D | Select next occurrence of current word |
Ctrl+Shift+L / Cmd+Shift+L | Select all occurrences of current word |
The Ctrl+D multi-cursor selection is particularly useful for renaming variables. Select a word, press Ctrl+D repeatedly to add cursors at each occurrence, then type the replacement.
Go to Symbol
Symbol search is more intelligent than text search because it understands code structure.
Symbols in current file: Ctrl+Shift+O / Cmd+Shift+O
Lists all symbols (functions, classes, variables, types) in the current file. Type @: to group by category (methods, properties, etc.).
Symbols in workspace: Ctrl+T / Cmd+T
Searches for symbols across all files in the workspace. This is faster than text search when you know the function or class name but not which file it is in.
Advanced: Regex Search Examples
Regular expression search is powerful for finding patterns rather than literal text.
Enable regex mode with Alt+R or click the .* button in the search bar.
Search in Open Editors Only
To limit your search to files that are currently open:
- Open the Search panel (
Ctrl+Shift+F) - Click the ellipsis (...) to expand options
- Click the book icon ("Search Only in Open Editors")
Or use the files to include field with ./ to search only in the current directory.
Keyboard Shortcuts Reference
| Action | Windows/Linux | Mac |
| Quick Open (file search) | Ctrl+P | Cmd+P |
| Command Palette | Ctrl+Shift+P | Cmd+Shift+P |
| Search in all files | Ctrl+Shift+F | Cmd+Shift+F |
| Replace in all files | Ctrl+Shift+H | Cmd+Shift+H |
| Find in current file | Ctrl+F | Cmd+F |
| Replace in current file | Ctrl+H | Cmd+H |
| Go to symbol in file | Ctrl+Shift+O | Cmd+Shift+O |
| Go to symbol in workspace | Ctrl+T | Cmd+T |
| Go to line | Ctrl+G | Ctrl+G |
| Next search result | F4 | F4 |
| Previous search result | Shift+F4 | Shift+F4 |
Configuring Search Behavior
Exclude files from search globally
In VS Code settings (Ctrl+, / Cmd+,), search for "files.exclude" or "search.exclude":
This keeps search results clean by hiding generated or third-party code.
Increase search result limits
By default, VS Code limits search results to 20,000. For very large codebases:
Use ripgrep for faster searching
VS Code uses ripgrep under the hood for its search functionality. It respects .gitignore files by default, which is why files in .gitignore do not appear in search results. To include gitignored files:
Common Pitfalls
- Forgetting
Ctrl+Shift+FvsCtrl+F.Ctrl+Fsearches the current file only.Ctrl+Shift+Fsearches all files in the workspace. The missingShiftis the most common reason for "I cannot find it anywhere." - Not using the include/exclude filters. Searching a large project without filters returns thousands of results from
node_modules,dist, and other generated directories. Always filter when needed. - Ignoring regex for pattern searches. Developers often search for function calls one at a time when a single regex could find all of them. Learning basic regex patterns saves significant time.
- Not knowing about symbol search.
Ctrl+Shift+OandCtrl+Tare faster than text search when you know the symbol name, because they understand code structure rather than just matching text. - Assuming search results are complete. VS Code caps results at 20,000 by default. If your search seems to be missing results in a large codebase, increase the
search.maxResultssetting. - Not using Quick Open for file switching. Many developers navigate the file tree manually.
Ctrl+Pwith fuzzy matching is almost always faster.
Summary
Ctrl+P/Cmd+Popens Quick Open for fast file-name search with fuzzy matching.Ctrl+Shift+F/Cmd+Shift+Fsearches text across all files in the workspace.- Use include/exclude glob patterns to filter results (
*.ts,!**/node_modules). Ctrl+Shift+O/Cmd+Shift+Osearches symbols in the current file.Ctrl+T/Cmd+Tsearches symbols across the workspace.- Enable regex mode (
Alt+R) for pattern-based searches like finding all TODO comments or function signatures. - Configure
search.excludein settings to permanently hide generated and third-party code from search results. - VS Code uses ripgrep internally, so search is fast even in large codebases and respects
.gitignoreby default.
Related reading
- How do I set a ViewModel on a window in XAML using DataContext property?
- How do I sort an observable collection?
- How do I specify the exit code of a console application in .NET?
- How do I split a string by a multi-character delimiter in C?
- How do I start a process from C?
- How do I stop a thread when my winform application closes
- How do I submit disabled input in ASP.NET MVC?
- How do I sync the SVN revision number with my ASP.NET web site?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.