How to search for files by name and text in all files in VS Code
Codemia Knowledge Hub ·
Press Ctrl+P (Windows/Linux) or Cmd+P (Mac) to find a file by name in VS Code. This opens Quick Open, which fuzzy-matches across every file in the workspace. To search text inside all files, press Ctrl+Shift+F / Cmd+Shift+F. Those two shortcuts cover most needs; the rest is below.
Quick Open: find a file by name
How it works
- Press
Ctrl+P/Cmd+P - Type any part of the file name
- Select from the filtered list and press
Enter
Matching is fuzzy, so you do not need the exact name. usrctrl matches UserController.ts, and pkgjsn matches package.json.
Quick Open prefixes
| 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 combine them: UserService.ts:25 opens that file at line 25.
Recently opened files
Quick Open lists recent files at the top before you type anything, which makes it a fast file switcher. Press Ctrl+P twice quickly to cycle through recent files (similar to Alt+Tab).
Search text in all files
Ctrl+Shift+F / Cmd+Shift+F 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
Match case, whole word and regex toggles
| 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
Click the ellipsis (...) below the search box or press Ctrl+Shift+J / Cmd+Shift+J to show 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
- 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.
Search within the current 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 |
Ctrl+D is handy for renaming: select a word, press Ctrl+D repeatedly to add a cursor at each occurrence, then type.
Go to Symbol
Symbol search understands code structure, so it beats text search when you know the name.
Symbols in current file: Ctrl+Shift+O / Cmd+Shift+O
Lists the functions, classes, variables and types in the file. Type @: to group by category (methods, properties, etc.).
Symbols in workspace: Ctrl+T / Cmd+T
Searches symbols across all files, useful when you know a function or class name but not its file.
Regex search examples
Turn on regex mode with Alt+R or the .* button.
Searching only open editors
- Open the Search panel (
Ctrl+Shift+F) - Click the ellipsis (...) to expand options
- Click the book icon ("Search Only in Open Editors")
Or put ./ in files to include to search only the current directory.
Search 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 |
Search settings
Excluding folders globally
In Settings (Ctrl+, / Cmd+,), look for "files.exclude" or "search.exclude":
This hides generated and third-party code from results.
Raising the result limit
VS Code caps results at 20,000 by default. For very large codebases:
Including gitignored files
Search runs on ripgrep, which respects .gitignore by default, so ignored files do not appear. To include them:
Why a search misses what you expect
Ctrl+Finstead ofCtrl+Shift+F.Ctrl+Fsearches only the current file. The missingShiftis the usual reason for "I cannot find it anywhere."- No include/exclude filters. Large projects return thousands of hits from
node_modules,distand other generated folders. - Searching one call at a time. A single regex can often find every variant at once.
- Skipping symbol search.
Ctrl+Shift+OandCtrl+Tare faster when you know the symbol name. - Hitting the result cap. If results seem incomplete in a big codebase, raise
search.maxResults. - Browsing the file tree by hand.
Ctrl+Pwith fuzzy matching is almost always faster.
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 courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.