Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude all files except for... #869

Open
TheColorRed opened this issue Dec 1, 2015 · 196 comments
Open

Exclude all files except for... #869

TheColorRed opened this issue Dec 1, 2015 · 196 comments
Assignees
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues file-glob File glob engine
Milestone

Comments

@TheColorRed
Copy link

The files exclude allows you to set true/false values, but it doesn't seem to take them completely into account.

For example, I would like to hide everything except for the scripts folder. You might then assume that this would do this:

{
    "files.exclude":
    {
        "**/*": true,
        "**/Scripts": false
    }
}

It does not do that, it just hides everything. In order to achieve this, you must list every file and directory except for the Scripts directory, and who knows how many directories there are and if a new directory/file gets added you then must edit the list to exclude those.

In the end, their should be a way to hide everything except for xxx.

@bpasero bpasero added the feature-request Request for new features or functionality label Dec 1, 2015
@bpasero bpasero removed their assignment Dec 1, 2015
@plantain-00
Copy link

The comments above the files.exclude says Configure glob patterns for excluding files and folders.. the glob can use ! to exclude files and folders(which is not implemented by vscode now). for example:

{
    // Configure glob patterns for excluding files and folders.
    "files.exclude": {
        "*.js": true,
        "!gulpfile.js": true
    }
}

@dhirschfeld
Copy link

Can an option be added to exclude everything in the .gitignore?

@bpasero
Copy link
Member

bpasero commented Dec 8, 2015

Using negated glob patterns with "!" is currently not supported.

@TheColorRed
Copy link
Author

.gitignore will only hide the items from a commit, not hide them within the Editor

@egamma egamma modified the milestone: Backlog Dec 10, 2015
@bpasero bpasero added the file-explorer Explorer widget issues label Dec 18, 2015
@hellogavin
Copy link

It's grate!!!

@xfoxfu
Copy link

xfoxfu commented Jan 30, 2016

👍 I also want negated glob patterns since I use Jakefile.js to describe Jake tasks for my TypeScript project.

@JAForbes
Copy link

JAForbes commented Feb 7, 2016

👍 I need negated glob files as we store our many services in node_modules under the same repo. We hide node_modules because it slows down the editor, and clutters the workspace. But we have to use directory symlinks so we can edit the specific services in another folder.

If we could exclude these folders from being ignored, we could remove the symlinks and significantly reduce the complexity of our project. (Another issue is, debugging node in a symlinked folder doesn't work in vscode, this would be solved by this feature also.)

@AdamAndersonFalafelSoftware

Yes, we need negated glob exclusions. In Node, the built-in place to put application-wide modules is in a node_modules folder. You would want to be able to exclude node_modules except for your project's modules under e.g. node_modules/_local so that you can easily navigate to your own modules without also including all the imported ones.

Edit: this glob already works for the scenario above:

{
    "search.exclude": {
        "**/node_modules": false,
        "**/node_modules/!(.local)": true,
        "**/bower_components": true
    }
}

@bpasero bpasero self-assigned this Mar 30, 2016
@skyaddict
Copy link

Would this feature allow me to exclude */.css but not */.cssx.css? Can anyone think of a way this could be done now?

@AdamAndersonFalafelSoftware

@skyaddict My last comment above should work for your scenario as well

@skyaddict
Copy link

Sorry to bother, but I have tried many derivations of the following, and I still can't seem to find the secret sauce.

"/Css": false,
"
/Css/*!(.cssx).css":true

"/Css": false,
"
/Css/!(*.cssx.css)":true

@JAForbes
Copy link

JAForbes commented Apr 4, 2016

@skyaddict it hasn't been implemented yet in vscode

@AdamAndersonFalafelSoftware

@JAForbes, @skyaddict: I was about to write a reply saying that it already works, but then a mystery was revealed. I can confirm that the search.excludes setting above works for excluding all subfolders of node_modules except for a folder named .local. That is 100% definitely working. However, I was not able to get the same set of patterns to work on a folder other than node_modules, or on individual files. So this issue definitely still needs attention.

@CreepGin
Copy link

So right now, vscode is not supporting extended globbing for their exclude options. Can someone briefly explain what the holdup is?

@J-Siu
Copy link

J-Siu commented Jun 27, 2016

I won't say it is a deal breaker but getting annoying not able to do this.

In angular 2 project we usually exclude all js file but still want to see a few js setting files, like webpack.config.js, systemjs.config.js, etc.

@chase-moskal
Copy link

Aw man, I'd sure love to see this working!

"files.exclude": {
  "node_modules/*": true,
  "!node_modules/susa": true,
}

Or maybe this:

"files.exclude": {
  "node_modules/*": true,
  "node_modules/susa": false,
}

Not sure if false could be equivalent to prefixing with "!". Maybe.

@bpasero bpasero removed their assignment Aug 17, 2016
@bladnman
Copy link

bladnman commented Sep 4, 2016

always having Sublime open so I can search specific files that VSC won't let me is quite painful. A negative pattern here sounds rather straight-forward.

@the-spyke
Copy link

the-spyke commented Oct 6, 2016

Yes, the issue with own modules in "node_modules" is really annoying...

@ywmail
Copy link

ywmail commented Oct 11, 2016

Yes - I also want the feature...

@TobiasKoller
Copy link

i wanted to hide all .js-files if there is an equal *.ts file.
I just added "__/
.js": { "when": "$(basename).ts"},
which excludes all js-files except js-files like gulpfile.js etc

@RandScullard
Copy link

@TobiasKoller you are a genius, sir, and I thank you! I only needed to modify it slightly to get it to work in my project:

"**/*.js": { "when": "$(basename).ts" },

@AdamAndersonFalafelSoftware

Some documentation on the behavior and syntax of the when-object would be greatly appreciated.

@luan
Copy link

luan commented Dec 16, 2022

Shameless plug, but I've been following this issue for a little while and made this extension. It's a bit brute-forcey, but works on my large monorepo pretty well.

https://marketplace.visualstudio.com/items?itemName=cfcluan.project-scopes&ssr=false

@bebbi
Copy link

bebbi commented Dec 19, 2022

We'd love to conditionally exclude a folder in a monorepo through the file.exclude mechanism:

Reason: public folder should be included if it's a nextjs app (=part of source), excluded if it's a gatsby app (=build directory).

We hoped these might work but they didn't:

  • Exclude it if it contains files only in a gatsby build directory
"**/public": { "when": "$(basename)/webpack.stats.json" },
  • Exclude it if a sibling file shows that it's gatsby
"**/public": { "when": "gatsby-config.js" },

@bartroozendaal
Copy link

bartroozendaal commented Dec 19, 2022

I've published an extension that makes it a bit easier to work in a monorepo with multiple teams. It can filter the files in the explorer based on the settings in a code-owners.json file. I've been using it for months now. It is tailored to our specific setup at work, so it may not work for you out of the box, but feel free to drop a question or a request in the market place

My monorepo

@MuhammadM1998
Copy link

Shameless plug, but I've been following this issue for a little while and made this extension. It's a bit brute-forcey, but works on my large monorepo pretty well.

https://marketplace.visualstudio.com/items?itemName=cfcluan.project-scopes&ssr=false

I gave this a try and didn't work, I had toggle excluded files extension and thought it might be the cause, I uninstalled toogle excluded files and this also didn't work

@luan
Copy link

luan commented Jan 15, 2023

Shameless plug, but I've been following this issue for a little while and made this extension. It's a bit brute-forcey, but works on my large monorepo pretty well.
https://marketplace.visualstudio.com/items?itemName=cfcluan.project-scopes&ssr=false

I gave this a try and didn't work, I had toggle excluded files extension and thought it might be the cause, I uninstalled toogle excluded files and this also didn't work

@MuhammadM1998 can you open an issue in https://github.com/luan/vscode-project-scopes with more details?

@MuhammadM1998
Copy link

@luan I would but actually I have nothing more to add? I installed the extension and followed the video but it didnt work as the video, Right clicking a folder and selecting always add (i forgot what its called) adds it to scope's include array in the settings json file but does nothing and the files still the same

@hitzhangjie
Copy link

hitzhangjie commented Feb 3, 2023

Even though we could write like this , the meaning is not clear, because the order may be changed. I think vscode could support more glob patterns to exclude some but keep specific files, for example:

*.js - {abc.js, def.js, h*.js, i*.js-{iii.js,ijj.js} }

This is very useful feature, especially the project is organized in a monorepo, there're too many folders, files we may care and not care.

@bartroozendaal
Copy link

bartroozendaal commented Sep 26, 2023

I haven't read all the comments here (...) but here's a thing. Under the hood, vscode uses https://github.com/BurntSushi/ripgrep

When using this app, it also passes a --no-config flag, basically ignoring any settings that a user might have in a ripgrep config file. I believe ripgrep is capable of excluding folders much better than vscode supports.

I would be happy to manually maintain a ripgrep config file to set it up to only look in folders I want (or basically, exclude the folders I don't want it to search).

In the vscode below hits for setting the --no-config would be removed (or made optional):
https://github.com/search?q=repo%3Amicrosoft%2Fvscode%20--no-config&type=code

Background: I have created an extension to help with working in a large monorepo with multiple teams. This change in vscode would benefit that: my extension would then also maintain that ripgrep config file

https://marketplace.visualstudio.com/items?itemName=RoozendaalOnline.mymonorepo

Note: created a feature request for removing the --no-config flag. Let's see if we can convince the team about this ;-)

#194101

Note 2: I also cloned the vscode sources, removed the above settings and tried it. It works like a charm.

@evanlemke
Copy link

My problem is that search.exclude inherits from files.exclude. I would like to be able hide linter configuration files like .prettierrc, while still being able to quick open or search in them.

{
  "files.exclude": {
    ".node-version": true,
    ".prettierrc": true,
  },
  "search.exclude": {
    // inherits from files.excludes
  },
  "search.include": {
    ".node-version": true,
    ".prettierrc": true,
  }
}

I would like to see either

  • the ability to disable search.excludes inheritance of files.exclude
  • a stand alone search.include setting

@bartroozendaal
Copy link

I think that if you add an entry in search.exclude (e.g. .prettierrc: false) it will still search the file (but I might be mistaken)

@anno73
Copy link

anno73 commented Feb 9, 2024

I need to work in a given directory structure of the form

  • base1/environment/region/application/somefile.txt
  • base2/application/anotherfile.txt

I have base1 and base2 folders added to workspace.

As there are a lot of applications the directory tree is very big and it is quite the effort to open the correct file, as somefile.txt exists in each of the directories. So e.g. CTRL-P gets you nowhere.

It really would be highly appreciated if it would be possible to view in a given path only unwanted projects and hide the rest. Something like

  • ignore base and below except
  • show base/environment/region/my_application and structure within

I tried several notations from this thread but of course none of them worked as expected.
Also search.exclude does not seem to be able to help. Too much repetitive typing as application names can be quite long and one can open only one file per search.

@gjsjohnmurray
Copy link
Contributor

@anno73 why don't you create a workspace consisting of these two folders?

  • path/to/base1/environment/region/application
  • path/to/base2/application

@anno73
Copy link

anno73 commented Feb 9, 2024

@gjsjohnmurray oh my bad. I forgot to mention that we have multiple different values for environment and region - a total of at least 6 combinations.

So when I'd add each application as a separate folder to the workspace I'd have a lot of "application" base/root folders and I do not know the environment or region.

My idea was to get rid of all the other applications and have a directory tree of all envs and regions for my application and not a list of all applications in every env & region.

@bartroozendaal
Copy link

bartroozendaal commented Feb 9, 2024 via email

@anno73
Copy link

anno73 commented Feb 9, 2024

The workspace currently has 4 different git repos.
Thanks, I will have a look.

@Tomino2112
Copy link

Tomino2112 commented Feb 22, 2024

Hi, There is support for very limited negation according to https://code.visualstudio.com/docs/editor/glob-patterns
I realise that this will not be solution for everyone, but in my case I wanted to exclude all node_modules apart from @sky*
After some trial error, I managed to do this:

"files.exclude": {
        "node_modules/[!@]*": true,
        "node_modules/@[!s]*": true,
        "node_modules/@s[!k]*": true,        
        "node_modules/@sk[!y]*": true, 
    },

Desperate measures for desperate times :)

@xieshuaix
Copy link

xieshuaix commented Feb 23, 2024

I really think this is a must have for working on a large repo where a single developer might only need to focus on few out of hundreds of files/modules, while also need to frequently change what to focus on depending on the project they are working on. Creating a workspace and adding what is needed by hand each time is not practical.

For instance, in my case, I work mainly on a large repo with 5 sub-repos (all needed as there are inter-dependencies) of a mix of languages, each of hundreds of files. Being a full-stack dev, I don't filter files out if matched (this implies your project has a very fine-grained definition of boundary of scopes/responsibilities), i.e. exclude all .cpp codes because I absolutely don't care about anything related to C++. I need to include a wide range of types of files by file name keywords, which are usually named after features or projects, i.e. for a full-stack project on a feature called "feat", include all files of pattern: featForm.js, FeatDB.cpp, feat.py, featServer.go and data files under dir: feat_samples.

If there is a simple way to suit the need to above or we dont' care about real product development, I would agree that an include feature is not needed.
Even if ripgrep or whatever under the hood of current file search engine does not comply, there must be a simple way for batch adding files if matched. In fact searching keywords in files of path matched by regex works really well and is blazingly fast, so adding files by regex is definitely feasible.

@bartroozendaal
Copy link

@xieshuaix If you are using a codeowners file in your repo (or can set one up to divide the code into 'categories'), you might want to checkout the mymonorepo extension. I use it daily in a very large repo with hundreds of teams and it works quite well (with some gotchas).

Disclaimer: I'm the author.

@Thaina
Copy link

Thaina commented May 26, 2024

I wish to know are there any reason or technical issue why we can't just support extended globbing pattern

@UchihaYuki
Copy link

Vote!!! It's been 10 years. I really need this function.

@touchmii
Copy link

Hi, There is support for very limited negation according to https://code.visualstudio.com/docs/editor/glob-patterns I realise that this will not be solution for everyone, but in my case I wanted to exclude all node_modules apart from @sky* After some trial error, I managed to do this:

"files.exclude": {
        "node_modules/[!@]*": true,
        "node_modules/@[!s]*": true,
        "node_modules/@s[!k]*": true,        
        "node_modules/@sk[!y]*": true, 
    },

Desperate measures for desperate times :)

Thank you. It's helped me out.

@JFCeron
Copy link

JFCeron commented Aug 31, 2024

This is outrageous negligence from the VSCode team.

@blakeanator
Copy link

How is this still an issue...?

@QuarticCat
Copy link

I just created a new extension: Scope Focus. It's similar to the Project Scopes above except that:

  • It works on workspace-level rather than user-level.
  • Its algorithm is simpler and presumably faster (only 2 glob calls per switch).

It's minimal for now. Feature requests are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues file-glob File glob engine
Projects
None yet
Development

Successfully merging a pull request may close this issue.