Search code examples
macosvisual-studio-code

Make VS Code ignore files under /var/folders/


When I use the "Go to file..." function in VS Code (command + P on mac), VS Code lists files under the /var/folders/... path.

Screenshot of the command palette

Selecting one of the files under /var/folders/ usually yields "The editor could not be opened because the file was not found.".

I'm pretty sure these are temporary files used by Git. The files under var/folders/ appear as "recently opened" when I use git history features; comparing the file with previous versions of itself.

Is there a way to set VS Code so that only files in the current working directory show up?


Solution

  • There used to be a bug in VSCode that causes /var/folders files can't be reliably excluded from search neither from search.exclude nor files.exclude.

    I collaborated with the VSCode team to fix this issue, since VSCode v1.88, use the following setting to exclude these files:

    {
      "search.exclude": {
        // exclude from global search and quick open
        "**/var/folders/**": true
        // exclude ONLY from global search
        // "**/var/folders": true
      }
    }