How to exclude specific directories from "go to definition" in vscode

I use CTRL+Click (or F12) to search and open the definitions in vscode. The problem is that my files are copied to another directory called sketch as I compile my code, so when I wanna open the definition of a function, VS shows both files (the real and the copied ones in the sketch folder), and sometimes I edit the copied file by mistake!

How can I exclude some folders from the "Go To definition"?


Solution 1:

I had the same problem in a Javascript project. None of the following solved it for me: files.exclude, files.watcherExclude, or search.exclude.

The solution was to add jsconfig.json to my project folder:

{
    "compilerOptions": {
        "target": "ES6"
    },

    "exclude": [
        "Backup",
        "Sketch"
    ]
}

This example specifies two folders to exclude: "Backup", and "Sketch".

If you are using TypeScript, use a tsconfig.json file instead.

Also see https://code.visualstudio.com/docs/languages/jsconfig