Visual Studio Code
File Search
Coding Tips
Software Development
Programming Tools

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.

Browse interview questions

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

  1. Press the shortcut
  2. Start typing any part of the file name
  3. 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:

PrefixBehaviorExample
(none)File searchUserService
>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.

  1. Press Ctrl+Shift+F / Cmd+Shift+F
  2. Type the text you are looking for
  3. Results appear grouped by file, with line previews
 
1# Example: searching for "handleSubmit"
2src/components/LoginForm.tsx
3  Line 14:   const handleSubmit = async (e: FormEvent) => {
4  Line 45:   <form onSubmit={handleSubmit}>
5
6src/components/RegisterForm.tsx
7  Line 22:   const handleSubmit = useCallback(() => {

Search options (the toggle buttons)

The search bar has three toggle buttons:

ButtonShortcutEffect
AaAlt+CCase-sensitive matching
AbAlt+WMatch whole word only
.*Alt+RUse 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.

 
1# Include only TypeScript files
2*.ts, *.tsx
3
4# Exclude test files and node_modules
5**/node_modules, **/*.test.ts, **/*.spec.ts

Glob patterns work here:

PatternMatches
*.tsAll TypeScript files
src/**/*.tsTypeScript files inside src/
!**/node_modulesExclude node_modules
*.{ts,tsx}TypeScript and TSX files

Replace across files

The search panel also supports find-and-replace across your entire workspace:

  1. Press Ctrl+Shift+H / Cmd+Shift+H (or expand the replace field in search)
  2. Enter the search term and replacement
  3. 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:

ShortcutAction
Ctrl+F / Cmd+FFind in current file
Ctrl+H / Cmd+HFind and replace in current file
F3 / Cmd+GJump to next match
Shift+F3 / Cmd+Shift+GJump to previous match
Ctrl+D / Cmd+DSelect next occurrence of current word
Ctrl+Shift+L / Cmd+Shift+LSelect 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.).

 
1# Typing @:method shows:
2  handleSubmit
3  validateForm
4  resetState

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.

 
# Typing "UserService" finds:
  class UserService  (src/services/UserService.ts)
  interface UserService  (src/types/services.ts)

Advanced: Regex Search Examples

Regular expression search is powerful for finding patterns rather than literal text.

 
1# Find all console.log statements
2console\.log\(.*\)
3
4# Find all TODO/FIXME comments
5(TODO|FIXME):?\s.*
6
7# Find all import statements from a specific package
8import\s+.*\s+from\s+['"]react['"]
9
10# Find all functions that start with "handle"
11(function|const|let|var)\s+handle\w+
12
13# Find all hex color codes
14#[0-9a-fA-F]{3,8}
15
16# Find all email-like patterns
17\w+@\w+\.\w+

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:

  1. Open the Search panel (Ctrl+Shift+F)
  2. Click the ellipsis (...) to expand options
  3. 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

ActionWindows/LinuxMac
Quick Open (file search)Ctrl+PCmd+P
Command PaletteCtrl+Shift+PCmd+Shift+P
Search in all filesCtrl+Shift+FCmd+Shift+F
Replace in all filesCtrl+Shift+HCmd+Shift+H
Find in current fileCtrl+FCmd+F
Replace in current fileCtrl+HCmd+H
Go to symbol in fileCtrl+Shift+OCmd+Shift+O
Go to symbol in workspaceCtrl+TCmd+T
Go to lineCtrl+GCtrl+G
Next search resultF4F4
Previous search resultShift+F4Shift+F4

Configuring Search Behavior

Exclude files from search globally

In VS Code settings (Ctrl+, / Cmd+,), search for "files.exclude" or "search.exclude":

json
1{
2  "search.exclude": {
3    "**/node_modules": true,
4    "**/dist": true,
5    "**/build": true,
6    "**/.git": true,
7    "**/coverage": true,
8    "**/*.min.js": true
9  }
10}

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:

json
{
  "search.maxResults": 50000
}

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:

json
{
  "search.useIgnoreFiles": false
}

Common Pitfalls

  • Forgetting Ctrl+Shift+F vs Ctrl+F. Ctrl+F searches the current file only. Ctrl+Shift+F searches all files in the workspace. The missing Shift is 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+O and Ctrl+T are 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.maxResults setting.
  • Not using Quick Open for file switching. Many developers navigate the file tree manually. Ctrl+P with fuzzy matching is almost always faster.

Summary

  • Ctrl+P / Cmd+P opens Quick Open for fast file-name search with fuzzy matching.
  • Ctrl+Shift+F / Cmd+Shift+F searches text across all files in the workspace.
  • Use include/exclude glob patterns to filter results (*.ts, !**/node_modules).
  • Ctrl+Shift+O / Cmd+Shift+O searches symbols in the current file. Ctrl+T / Cmd+T searches symbols across the workspace.
  • Enable regex mode (Alt+R) for pattern-based searches like finding all TODO comments or function signatures.
  • Configure search.exclude in 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 .gitignore by default.

Related reading
Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Track 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.

Browse interview questions

All Rights Reserved.