Find / Replace
Find / Replace in VS Code is feature-rich: regex, case, whole-word, in-folder, in-files-by-glob, with capture groups, and a multi-cursor mode for the matches.
Every find / replace shortcut + a real refactor
EXAMPLE
# File search
# Ctrl + F — find
# Ctrl + H — replace
# Alt + Enter — multi-cursor at all matches
# F3 / Shift + F3 — next / previous match
# Toggle modes
# Alt + R — regex on / off
# Alt + C — case sensitive on / off
# Alt + W — whole word on / off
# Project-wide search
# Ctrl + Shift + F — search across the workspace
# Ctrl + Shift + H — replace across the workspace
# files to include: src/**/*.{ts,tsx}
# files to exclude: **/*.{test,spec}.ts, dist/**
# Real refactors — regex + capture groups
# Rename 'logger.error("msg")' to 'logger.warn("msg")'
Find: logger\.error\("([^"]+)"\)
Replace: logger.warn("\$1")
# Convert var → const everywhere
Find: \bvar\b
Replace: const
# Turn snake_case keys into camelCase
Find: "([a-z]+)_([a-z]+)":
Replace: "\$1\u\$2": # \u uppercases next char in many engines
# Reorder named imports
Find: import \{ ([A-Z]\w+), ([A-Z]\w+) \}
Replace: import { \$2, \$1 }
# Replace in a SINGLE file (current editor)
# Ctrl + H, then Ctrl + Alt + Enter — replace all without prompt
# Search history
# Alt + ↑ / Alt + ↓ — previous queries
# Open results as a virtual editor
# Click 'Open in editor' in the search panel — edit results then save / commit
Why it matters
Pair regex find + multi-cursor (Alt + Enter). The cursors land at every match across the file — far more flexible than blind “Replace All” when you need to tweak each occurrence differently.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
// Find: Ctrl + F // Replace: Ctrl + H // Project-wide: Ctrl + Shift + F / H // Toggle regex / case / whole word with the icons in the search box. // Capture groups: $1 $2 in the replacement.Try it Yourself »
Discussion
Loading…