Ignore files or folders in VS Code

Viewed 6233

I have a /builds directory that has some compiled JS inside and I find myself accidentally editing files in there rather than the ones in the rest of the project that I want to edit because Cmd-T brings up 2 files and I just pick the first, quickly.

How can I ignore a file or a directory in my specific project in VS Code? Thanks!

3 Answers

What I recommend:

Create a file in the root of your application named myProject.code-workspace and edit it like this:

{
  "folders": [
    {
      "path": "."
    }
  ],
  "settings": {
    "search.exclude": {
      "**/node_modules": true,
    },
    "files.exclude": {
      "**/android": true,
      "**/ios": true,
    },
    "editor.formatOnSave": true, // not needed
  }
}

In this way your project will ignore the files in the "explore" tab. if you want to exclude the files only for the search environment, add it to search.exclude, otherwise to files.exclude in the settings rules. You can add/edit as you want.

VSCode will detect that file and consider it as the JSON for the workspace config. Don't forget to open this workspace in your VSCode by going to file > open workspace and select this file.

For more info: https://code.visualstudio.com/docs/getstarted/settings

First open settings: in OSX "CMD + ,". Or go to the menu Code -> Preferences -> Settings. Or search "open user settings" in the commmand palette: Search settings in VSCode

In Features -> Search press the Add Pattern button. Write your folder name, like the examples.

Important: If the folder has to be excluded for several projects, set this in the user tab (at the top of the screen), as a global setting. But, if this is only a one-time setting, switch to the workspace tab (next to User).

Related