VS Code Find and Replace Keyboard Shortcut
This article provides the exact keyboard shortcuts for finding and replacing text within a single file in Visual Studio Code (VS Code). You will learn the specific key combinations for Windows, Linux, and macOS, as well as a quick guide on how to use the find and replace interface efficiently.
The Keyboard Shortcuts
To quickly open the Find and Replace widget within your active file, use the following keyboard shortcuts:
- Windows and Linux:
Ctrl+H - macOS:
Option+Command+F(or⌥+⌘+F)
Note: If you already have the standard Find widget open (via
Ctrl + F or Cmd +
F), you can toggle the replace field by clicking the small
chevron arrow on the left side of the search bar.
How to Use Find and Replace in a File
Once the widget appears in the top-right corner of your editor, you will see two main text fields:
- Find Field (Top): Type the text you want to locate.
- Replace Field (Bottom): Type the new text you want to insert.
Executing the Replacement
You can use the buttons on the right side of the widget or use these keyboard shortcuts to apply your changes:
- Replace Single Instance: Click the
Replace button (represented by a single paper/arrow
icon) or press
Ctrl+Shift+1(Windows/Linux) orCmd+Shift+1(macOS). - Replace All Instances: Click the Replace
All button (represented by a stacked paper/arrow icon) or press
Ctrl+Alt+Enter(Windows/Linux) orCmd+Alt+Enter(macOS).
Search Modifiers
To refine your search, you can toggle three options located on the right side of the “Find” input box:
- Match Case (
Aa): Limits results to exact uppercase and lowercase matches. - Match Whole Word (
ab): Prevents the tool from finding text that is part of a larger word (e.g., searching for “pin” will not highlight “spinning”). - Use Regular Expression (
.*): Enables the use of regex patterns for advanced searching and dynamic replacements.