How do I find and replace all occurrences (in all files) in Visual Studio Code?

Since version 1.3 of vscode this is possible

  1. Navigate to the search, click icon to the left or:
    • (mac) cmd + shift + h
    • (PC) ctrl + shift + h
  2. expand replace
  3. enter search term and replace term
  4. confirm!

Search and replace with vscode


I'm using Visual Studio Code 1.8, and this feature is available. But it's a little tricky to understand at first, and (at the time of writing) the docs don't explain clearly how to use it, so here's how it works, step by step:

Invoke Replace in Files (under the Edit menu, or with shortcut Ctrl+Shift+H)

You'll see a standard Find/Replace input replacing the files pane on the left:

enter image description here

Enter your search string and the replace string, then press enter. It may churn for a second searching all files, then it'll show the proposed changes in all your project files -- but note, these changes haven't been made yet! Here's what it looks like:

enter image description here

Now you need to make the changes (and even after that, you have to save the modified files.)

You can make those changes in various ways:

  1. Make all changes to all files at once.

Click the replace icon next to your replace string (note: you'll get a dialog to confirm this bulk action.)

enter image description here

  1. Make all changes in a single file at once.

Click the replace icon next to the filename (note: the icon only shows up when you hover over the filename row)

enter image description here

  1. Make a single change in a single file.

Click the replace icon next to the individual change: (note: the icon only shows up when you hover over the change row)

enter image description here

Finally, don't forget to save!

All those files are now modified in the editor and not yet saved to disk (unless Auto Save is on).

Use File -> Save All (or Ctrl+Alt+S)

Update: I'm not sure when this was added, but if you click the "Replace all" button and see this dialog, clicking "Replace" will change and save all files in one click:

enter image description here