8

In Visual Studio Code, when I perform a search that is not "narrow" on a vast folder, I get an error message stating the following:

The result set only contains a subset of all matches. Be more specific in your search to narrow down the results.

Is there a way/setting to avoid this message and continue the search in Visual Studio Code?

The search is expected to return about 50,000 - 70,000 matches.

9
  • if you want to see them all use a grep on the command line and use file redirection, you are not going to visit each of the 50k+ hits in the editor, then open the result file and search here
    – rioV8
    Commented Aug 18, 2022 at 12:25
  • @rioV8 Hi, thanks for trying to help. Well, my bad for not mentioning this minor detail in my question which is that I will be performing a search/replaceAll operation on these records, and secondly I don't really know much about grep so I need a solution that is VSCode specific, if possible. If not, then can you explain how this would work in grep? thanks in advance. Commented Aug 18, 2022 at 14:53
  • @rioV8 Also, don't worry about the specs in case you are wondering, the machine I am working on is actually 256GB of ram and a decent CPU so it won't be a problem to perform this search/replaceAll. Commented Aug 18, 2022 at 14:54
  • for really large search replace I use a python script with arguments to control what and which files. If you want to use VSC make sure that you can do the search/replace in batches, the search does not match replaced items, maybe you need to add an unused char sequence @#@# and in pass 2 remove this char sequence from the files. VSC has a limit on the max multi cursors, I have to deal with it, VSC has a limit on the max file size you can open with vscode.open
    – rioV8
    Commented Aug 18, 2022 at 17:10
  • 2
    @rioV8 Actually, I rechecked and it turns out that -1 was used in very old versions of VS Code and now you can leave it empty/null to make it unlimited. Commented Aug 19, 2022 at 14:46

1 Answer 1

22
+250

The solution for this is already in Visual Studio Code.

Here are the steps:

  1. You go to the settings of Visual Studio Code by pressing Ctrl/Cmd + Shift + P and searching for an option that goes Preferences: Open User Settings, click it.
  2. In the settings section there will be a search bar with the placeholder of "Search settings", in it type, "Search: Max Results".
  3. By now, there will be an option with the heading of Search: Max Results and a default value (at the time of writing) of "20,000", change that to a higher number like "100,000" or to empty/null (to make it completely unlimited), and save the settings.

Or add the following to your settings.json file with whatever maximum value you'd like:

{
  "search.maxResults": 40000
}

You should now be able to perform search/replace operations with larger search results in Visual Studio Code.

See Also: Add search.maxResults setting #126762

1
  • 1
    thanks man, you saved me many hours 🙏 Commented Jul 7, 2023 at 6:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.