11

I've been wanting to move from PhpStorm to VS code, but one of the things I don't like about VS Code is how slow its built-in Search feature is at finding text within the files of a large project.

PhpStorm is really good for this and, for me, is an essential feature. I can understand that PhpStorm is good at this because it is indexing all the files in the project beforehand.

Is there any way I can make VS Code search faster?

Gama11
  • 31,714
  • 9
  • 78
  • 100
MakkyNZ
  • 2,215
  • 5
  • 33
  • 53
  • Improve the search performance and create a pull request for it on GitHub ;-) Now seriously: Search performance is a matter in VSCode and it has improved over the time. Unfortunately it is still not as fast as other editors and IDEs. From a user's point of view you can only vote for improving the file search. It's a planned item for November and December updates as you can see here: https://github.com/Microsoft/vscode/issues/15384 – Wosi Nov 15 '16 at 14:40
  • 1
    March 2019 and this problem is still not solved. Why not have a look at Notepad++? The search through files is very fast. And it is open source: https://github.com/notepad-plus-plus – Avatar Mar 18 '19 at 14:02
  • Currently to speed up search vscode recommends adding to the `search.exclude`. The files.exclude will remove the ide recognition entirely in the explorer. – Urasquirrel Aug 19 '21 at 18:21

2 Answers2

12

It may be as simple as telling VS Code not to index / search certain folders. Are there /vendor or /dist folders that you don't want to search through? Try this:

  • Do one of your slow searches
  • Look through the files that get returned
  • See if there are files being returned in a folder you don't care about

For each of these folders, add them to the files.exclude section of your settings file:

"files.exclude": {
  "**/dist*": true,
  "**/node_modules*": true
},

If there are any really large files that show up in the search, add those too.

The fewer files the search needs to deal with, the faster it will go.

Update Oct 2021

You should now use search.exclude instead of files.exclude, as files.exclude will remove the files from search, but will also remove the files from your file tree in the leftnav. search.exclude only filters them out of search.

"search.exclude": {
  "**/dist*": true,
  "**/node_modules*": true
},
Dan Caddigan
  • 1,578
  • 14
  • 25
  • where is the settings file? – ionescho Feb 19 '21 at 14:14
  • 2
    Ctrl+, (control and comma key) ... or (on windows) go to "File" > "Preferences" > "Settings" in the top menu and then on the settings page search for "search", scroll a bit to find a section called "Search: Exclude" – chrisweb Mar 23 '21 at 18:06
  • 1
    Also, take notice there is a Clog icon in the search siderbar inside "files to exclude" field. If that's not active, your .exclude settings will be ignored. – MMalke Jun 23 '21 at 00:13
  • 1
    Currently to speed up search vscode recommends adding to the search.exclude. The one you have mentioned files.exclude will remove them from the ide recognition entirely in the explorer. – Urasquirrel Aug 19 '21 at 18:19
  • 1
    They should use a search cache like IntellijIDEA, Searching thousand of files in less than 1 minute. – MaXi32 Dec 20 '21 at 16:00
  • possibly this is Mac only? (I find is ok on Windows + Ubuntu, but not on Mac) note: although there are both Files and Search settings, VS Code says that Search exclude "Inherits all glob patterns from the Files: Exclude setting." My `.vscode` file: ``` { "files.exclude": { "**/node_modules": true } } ``` – Sean Jan 09 '22 at 14:55
0

There is a new fast search implementation in vscode. For when you just want to do a quick, simple search (i.e., no regex, no replace, none of the usual find options like matchWholeWord, etc.) in the workspace. It is available for testing now in Insiders v1.82.

It appears to use the Find widget as the query field for that widget will be filled with the search term you type in and thereafter you can use things like the command Select All Occurrences of Find Match in the file you go to. Results are grouped by file. Click on an entry to go to that file and line number.

Search: Quick Text Search (Experimental)   // in the Command Palette
workbench.action.experimental.quickTextSearch   // to be used in a keybinding

The command is unbound to a keybinding but you can make your own like this:

{
  "key": "alt+q",
  "command": "workbench.action.experimental.quickTextSearch"
}

quick search text demo

You can rightArrow on any entry in the list and it will open in thebackground without losing focus on the quickPanel.

Clicking on the entry or hitting Enter will go to that entry and close the QuickPanel.

Mark
  • 143,421
  • 24
  • 428
  • 436