Reputation: 1691
I usually work on larger projects with many files that would contain the search query. So I would open the files I want to modify and do a find/replace across all currently opened files. Can this be done in vs code?
The feature I'm looking for is implemented in Notepad++, but I'd prefer not to have to switch editors for this task.
Upvotes: 105
Views: 37579
Reputation: 180631
The ability to search only in the open editors is in the Stable Build v1.55.
As you can see, the icon is at the end of the files to include
input so you will have to have that showing (click the three dots ...
just below the search options if files to include
is not already showing).
Upvotes: 93
Reputation: 11
This extension is what I use for this purpose. You may need to change the keybinding if there is a conflict.
Upvotes: 1
Reputation: 81
The best way to find something you are searching for within a specific file in vs code would be:
@
on the search bar.It will give you a list of all functions on the file, which makes it easier to track something down.
Upvotes: 1
Reputation: 43
The answer was already mentioned (and accepted above) indeed typing ./
in the files to exclude box of the search window will allow you to only search in open files.
However the response mentioned that he was unsure why this worked. VSCode allows you to exclude all files in a directory by writing the directory in the exclude box. The directory .
is the directory where VSCode is opened ie the root directory. The filter ./
excludes all files in the VSCodes root directory so all files are excluded. However opened files ignore any exclude filter. So if you exclude all files only the opened files will be searched.
Upvotes: 1
Reputation: 478
Hit Ctrl + Shift + F and enable the icon at the end of the 'file to include' text field
Upvotes: 10
Reputation: 107
There is a checkbox for this in the "files to include" field since version 1.55 (march 2021).
Upvotes: 3
Reputation: 721
For me somehow it works just by typing ./
in the files to exclude field.
Upvotes: 55
Reputation: 169
As an alternative to using Visual Studio Code itself, you can just search the file contents within the folder where unsaved files open in Visual Studio Code are located. This would be in one of these locations depending on which OS you are running:
Upvotes: 1
Reputation: 2929
"Search: target particular set of files #20530" located here: https://github.com/Microsoft/vscode/issues/20530
Is tracking a search "scope" such as "all open files".
Upvotes: 17
Reputation: 16089
I don't think there's a way to do this. You can make a feature request on github. I think an extension could do it though.
Upvotes: 5