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

Viewed 944

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"?

2 Answers

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

Add files to C:\Users\user\AppData\Roaming\Code\User\settings.json:

"files.exclude": {
    "**/sketch": true
},

Or files to exclude when searching (in files):

"files.watcherExclude": {
    "**/*.x": true,
},
Related