My VS Code sometimes is not able to find files (via file search triggered with CTRL P) that are located outside of src folder in project. It does find them if they were used recently, but not otherwise. Also sometimes finds other files that are in the same location as the sought file, but not the ones I was looking for. Eg. if I search for .env
(which is located in main folder), a file called .env.sample
is found, but .env
is not - although they are located in the same folder.
What might be causing this strange behavior?
CodePudding user response:
First, check your .gitignore
. VSCode will exclude files in .gitignore
from QuickSearch.
If that's not the source of your problems, make sure VSCode is searching in the right place, and not searching where it shouldn't.
There is a default exclude setting for both Search and QuickSearch (Ctrl P) which looks like the one below. You can check your own with >Preferences: Open Default Settings (JSON)
.
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
It is possible to override these in the Search tab using the files to include ...
... or globally (which will enable it for QuickSearch too), in your user settings.json (>Preferences: Open Settings (JSON)
) with:
"search.useGlobalIgnoreFiles": false,
"search.useParentIgnoreFiles": false,
"search.exclude": {
"**/node_modules": false,
"**/bower_components": false,
"**/*.code-search": false
}
Note, some directories are excluded by default because searching through them is quite slow. Therefore, if you have a large directory that VSCode searches through, it's better to exclude it from the search.