aspdeepak
aspdeepak

Reputation: 2781

Visual Studio Code: How to actually search and replace a word in all files?

Env

Problem

I can search occurrences in all files by Ctrl + Shift + F

However, I can't find a way to search and replace occurrences in all files.

Is this a missing(or hidden) feature in Visual Studio Code.

Upvotes: 38

Views: 80918

Answers (5)

Shaiful Islam
Shaiful Islam

Reputation: 442

All File:

Search =  Ctrl + Shift + F 
Replace =  Ctrl + Shift + H 

One File:

Search =  Ctrl + F 
Replace =  Ctrl + H 

Upvotes: 0

VonC
VonC

Reputation: 1324278

As an enhancement, VSCode 1.70 supports search and replace in all selected files, solving the 2018 issue 47166 "Make search tree context menu multiselect-aware".

See PR 154847 (available today in VSCode insiders)

Make search tree context menu multiselect-aware

When multiple entries are selected, if someone removes/replaces on one selected item, it happens to everything.

Note: if a whole file (uses Replace All) and entry (just uses Replace) are both selected at once and either Replace or Replace All is used, whatever replace action is valid for all selected item will run.

For example, if a file and entry are all selected and the Replace button is selected on the entry, then Replace All will be run on the file and Replace will be run on the entry.

https://user-images.githubusercontent.com/31675041/178347470-174e2b08-307e-47ac-a0c2-0a726738b5c5.gif

Example:

https://camo.githubusercontent.com/52ffd85f2166bb5580d7be74b527423801c36d4f58a67eefd1b0f77d26451cc4/68747470733a2f2f692e6779617a6f2e636f6d2f64636462376338613066643836323930383339663733636630376436356330322e676966

Upvotes: 1

robstarbuck
robstarbuck

Reputation: 8091

VS Code also supports capturing groups when using regex, captured groups (using parenthesis) can be referenced with $1 for the first match, $2 the second etc. $0 returns the complete match.

Reversing "abc"

Reversing direction of "abc"

Appending "def"

Appending "def"

Upvotes: 11

aspdeepak
aspdeepak

Reputation: 2781

Visual Studio Code v 1.3.0++ has this feature:

Replace functionality can be accessed:

  • In the Search View by expanding the Search textbox
  • Using Ctrl + Shift + H, from the Edit | Replace in Files menu
  • Using Replace in Files command in the Command Palette

Global Search and replace

Upvotes: 52

Wosi
Wosi

Reputation: 45243

It's currently not possible to replace in all files. The good news is it's part of the June Iteration Plan. The feature has already passed a couple of tests. So it will be probably released in July 2016.

Upvotes: 3

Related Questions