Newaj
Newaj

Reputation: 4450

How to hide autogenerated files from VS code

I want to hide auto generated dart files like .g.dart, .freezed.dart from vs code project. How to do that?

Upvotes: 13

Views: 7944

Answers (4)

Mark
Mark

Reputation: 180885

In v1.67 you can create an entry in the

Explorer > File Nesting: Patterns setting like so:

*.dart $(capture).g.dart, $(capture).freezed.dart

file nesting in dart demo

explorer.fileNesting.enabled: Controls whether file nesting is enabled
explorer.fileNesting.expand: Controls whether file nests show as expanded by default
explorer.fileNesting.patterns: Controls how files get nested


In addition the Explorer: Sort Order setting has a new option:

foldersNestsFiles: Files and folders are sorted by their names. Folders are displayed before files. Files with nested children are displayed before other files.

sortOrder.foldersNestsFiles

See also v1.67b Release Notes: File Nesting

Make sure you have Explorer > File Nesting: Enabled true

Upvotes: 22

Lucas Breitembach
Lucas Breitembach

Reputation: 1683

create a folder

.vscode

create

settings.json

put this:

{
  "files.exclude": {
    "**/*.freezed.dart": true,
    "**/*.g.dart": true
  },
}

this make local configuration in your project.

Upvotes: 24

cumul
cumul

Reputation: 874

TL;DR

Type Ctrl/Cmd + Shift + p, choose Preferences: Open Settings (JSON) or Preferences: Open Workspace Settings (JSON) and add:

"files.exclude": {
    "**/*.freezed.dart": true,
    "**/*.g.dart": true
},

You can add more patterns if you like. Here you can find more information about the patterns.

More info

You can configure this in your workspace or user settings:

Open settings: Ctrl/Cmd + Shift + p and search for 'Preferences: Open Settings'. You can choose from 'Workspace Settings' or your 'User Settings', depending on if you want to exclude the files just in your current project (workspace) or for all projects. And you can choose if you want to use the UI tool or to modify the settings json file manually.

Using the UI tool:

Search for files.exclude and you can add patterns you want to hide in the project explorer. In your case add **/*.freezed.dart and **/*.g.dart, but you can exclude any pattern you like.

Editing the json file manually:

Type Ctrl/Cmd + Shift + p and search for 'Preferences: Open Settings (JSON)' or Preferences: Open Workspace Settings (JSON). Again, depending on if you want to exclude the files just in your current project (workspace) or for all projects.

Add this part to the json file:

"files.exclude": {
    "**/*.freezed.dart": true,
    "**/*.g.dart": true
},

Or add just the pattern lines, if files.exclude is already present in the settings.json file.

Upvotes: 9

Carlos
Carlos

Reputation: 111

"On Mac. Open VSCode, Type Shift+Command+P, Preferences: Configure, Language Specific Settings, Choose the Language (Dart), Then add to file "

"files.exclude": { "/.git": true, "/.svn": true, "/.hg": true, "/CVS": true, "/.DS_Store": true, "/*.g.dart":true, }

Save

Now, you don't see the *.g.dart files.

Upvotes: 2

Related Questions