Visual Studio Code
File Search
Coding Tips
Software Development
Programming Tools

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

  1. Press Ctrl+P / Cmd+P
  2. Type any part of the file name
  3. 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

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 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.

  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(() => {

Match case, whole word and regex toggles

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

 
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

  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.

Search within the current 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

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.).

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

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.

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

Regex search examples

 
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+

Turn on regex mode with Alt+R or the .* button.

Searching only open editors

  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 put ./ in files to include to search only the current directory.

Search 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

Search settings

Excluding folders globally

In Settings (Ctrl+, / Cmd+,), look 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 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:

json
{
  "search.maxResults": 50000
}

Including gitignored files

Search runs on ripgrep, which respects .gitignore by default, so ignored files do not appear. To include them:

json
{
  "search.useIgnoreFiles": false
}

Why a search misses what you expect

  • Ctrl+F instead of Ctrl+Shift+F. Ctrl+F searches only the current file. The missing Shift is the usual reason for "I cannot find it anywhere."
  • No include/exclude filters. Large projects return thousands of hits from node_modules, dist and other generated folders.
  • Searching one call at a time. A single regex can often find every variant at once.
  • Skipping symbol search. Ctrl+Shift+O and Ctrl+T are 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+P with fuzzy matching is almost always faster.

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
Data 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.

Practice algorithms