Is it possible to exclude test files when doing a grep search in VS Code?
I would have thought one of these regexes would have worked
^/(?!Test$)[a-z0-9]+$
Or
^/(?!Test)([a-z0-9]+)$
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communitySearch in VS Code doesn't utilize regex in excluding files (see open issue). It is configured with glob patterns. So you can still do the following:
*Test.cls
This, of course, assumes your test classes are named with test
at the end (ex. MyControllerTest.cls
). If it's in the front just flip that around
Test*.cls
Likewise, you can include multiple paths to exclude to cover different permutations by separating them with a comma:
*test.cls, *Test.cls, Test*.cls
If you don't want to specify each time, you can edit your workspace/user settings (File --> Preferences --> Settings)
As the documentation notes, excluding a file pattern in the settings has a slight difference than directly in the search.
Note that glob patterns in the search view work differently than in settings such as files.exclude and search.exclude. In the settings, you must use **/example to match a folder named example in subfolder folder1/example in your workspace. In the search view, the ** prefix is assumed. The glob patterns in these settings are always evaluated relative to the path of the workspace folder.