Open TheColorRed opened 8 years ago
My example: I would love to create a project-view consisting only of CMakeLists.txt files -- everything else, especially folders that do not contain CMakeLists.txt -- excluded from the file pane. This would make it much easier to navigate and build understanding of the structure without seeing anything distracting.
I would love to have this feature -- sometimes I need to dive into a particular one of my project's node_modules dependencies. I'd really like to mark that package as not excluded and be able to browser the code, set breakpoints, etc with a minimum of fuss... I'm sure this must be a common need ...
Can't believe this issue has been opened for 1 year and a half. The files.exclude
config states that it takes a glob, and glob do support the ! pattern.
Anyway, stumbling on this too, this is the kind of details that make VSCode a no-go (for now).
Here's a basic patch that adds a "files.include" config to allow you to selectively approve of a restricted set of files/folders. Note that it needs a lot more work before its production ready. add_include_only_ability.patch.txt
@Zephir77167 You are so correct with that, every 3-4 months I decide to give "VS Code" a change just to find out it's no good for large scale apps...
To all those suggesting to use negation or a negative character class (! or ^) have you tested it? In all my tests and from what I saw in source, there seems to be no support for either ! or ^. So all the suggestions made except in this comment will NOT work.
Wish this had at least the limited flexibility of standard glob even if no regex.
For me at least, the suggestions of @tobia worked well. I wanted to exclude all folders in the github.com folder of my golang project except those I was interested in. Adding the following to my local workspace config was good enough for me.
{
// Hide all folders expect those beginning with K
"files.exclude": {
"**/github.com/[^K]*": true,
}
}
@CharlesWinter I can't get this to work.
"files.exclude": {
"**/out/*/*.[^h]": true
},
Trying to exclude all files except .h files. No dice...
@csholmq That will most likely be because that regex is looking for files starting with the character h due to the ^. Remove that should give you some more success.
@CharlesWinter How do you mean? I am expecting the ^ to negate the literal character h and thus match all files except those with the letter h. Am I missing something trivial?
Why not provide a configure called "file.include" ? #feature request
Actually, this false option doesn't work
"files.exclude": { "node_modules": true, "node_modules/susa": false }
From the intelligence prompt of VSC, it only control if the pattern is enabled.
"files.exclude": { "node_modules": true, "!node_modules/susa": true }
The negative pattern doesn't work either.
Anyone who is working on this?
Really need this feature!
https://github.com/Microsoft/vscode/issues/869#issuecomment-255660177 how would you hide the js file when either ts
or tsx
file exist?
Any progress on this?
Until this is implemented, has anyone found an extension that does this?
In the search tab you can define exclude
and include
. So exclude true / false is maybe a bit confusing.
The value true
is only set to have a valid json. Ok, otherwise an array would be a better way to define that. ["firstPath", "anotherPath"]
My suggestion:
{
"search.exclude": {
"**": true
},
"search.include": {
"/src": true
}
}
this allows to only search in src-folder.
include
> exclude
Include should be evaluated after exclude.
To avoid confusion about the boolean value and keep a valid json you can use an array.
{
"search.exclude": ["**"],
"search.include": ["/src"]
}
I don't know what's the reason for the object?
This is driving me insane. My files.exclude is starting become this long mess, when it could all be achieved in one files.include line. This seriously needs attention!
I really need this as well for AWS Lambda's flat package style requirement of putting dependencies right next to your code:
# gitignore all files within apps/<myapp>/src EXCEPT for a single app folder
apps/*/src/*
!apps/*/src/app
@bpasero : What is the progress with regard to the issue ? There is a lot of conversations regarding the work around for the problem. And seems to me nothing is solving my problem. So, can you please take a look at how you can solve the problem ? Many of developers like me are waiting for an enhancement to specify "everything expect" in files.exclude or another configuration such as files.include.
This issue has been opened for three years... I tried every method that mentioned above, none of them works...
In my scenario I want to hide all files that start with a .
but not the .vscode
folder.
For now I'm using this:
"files.exclude": {
".[^v]*": true,
}
Which unfortunately means that I can't use any tools that start with a v
😄
After three years Microsoft still didn't bother to resolve this 2-hour issue. It remains only to close discussion for collaborators and that's all
Not only does it not work, there's no way to disable hard-coded exclude entries in Workspace or User, even using "/pattern/": false doesn't work.
A workaround I use is to just use the "files to exclude" and "files to include" in the sidebar search.
I need Explorer to show only the folders (and all beneath them) matching (against the full path) given pattern& For example, if I type QSL/Backorder
, it would only display the following folders:
./classes/XLite/Module/QSL/Backorder/**
./skins/admin/modules/QSL/Backorder/**
./skins/customer/modules/QSL/Backorder/**
And hide all others. Is there anything I can do at the moment to achieve this? Maybe, and extension?
The following workaround worked for me :heavy_check_mark:
I wanted to exclude /node_modules but include /node_modules/asch-core for search.
In the .vscode/settings.json file I configured:
{
"search.exclude": {
"**/node_modules/": true,
},
"search.useIgnoreFiles": false,
"search.useGlobalIgnoreFiles": false
}
search.useIgnoreFiles: false → search uses .gitignore files: no search.useGlobalIgnoreFiles: false → search uses global .gitignore files: no
On the left panel I untoggled the "Use Exclude Settings and Ignore Files"
Then I added the directory I wanted to include (in my case: /node_modules/asch-core, /*) into the files to include TextBox.
I needed this to exclude all the other stuff on /vendor
except the /vendor/symfony
, so i can use the intellisense autocompletion.
Create symlink object mklink /j "_include" "/vendor/symfony"
(You need to use CMD.exe)
Now exclude **/vendor, and done.
Now my _include
folder redirect to symfony codes(vendor/symfony)
, without being excluded from VSCode, while hiding everything of vendor folder, making the intellisense caching fast.
I would really like to hide all of the files that have no '.' in their name (except for "makefile".
I have tried "**/*.*": true
and it will INCLUDE the exact list of files I want to EXCLUDE. One would think that changing 'true' to 'false' would produce the opposite result but instead, it excludes nothing.
I also tried "**/!(*.*)": true
(and false) and neither of these exclude any files.
Finally, I tried "!(**/*.*)": true
(and false) and nothing was excluded.
So is it possible to exclude all files without a dot in their name and if so, how?
[Currently using VS Code Version 1.31.0-insider]
Here's my way to except /node_modules/foo from the exclude,
"files.exclude": {
"**/node_modules/{[^f],?[^o],??[^o]}*": true
}
To anyone having trouble using negative character classes (e.g. [^x]
)...
I discovered that at least on my system, VSCode's implementation of globs breaks depending on the length of the pattern and how many character classes you put into the pattern.
For example, let's say you were trying to exclude all vendor directories except foobar
.
This will work:
"**/vendor/[^f]*": true,
"**/vendor/f[^o]*": true,
"**/vendor/fo[^o]*": true,
"**/vendor/foo[^b]*": true,
"**/vendor/foob[^a]*": true,
"**/vendor/fooba[^r]*": true,
"**/vendor/foobar?*": true,
This will not work:
"**/vendor/[^f][^o][^o][^b][^a][^r]*": true,
"**/vendor/foobar?*": true,
I can't quite work out the exact rules for when it breaks, but if you want it to be bulletproof, try it with the working example above.
If you need to do this for more than one directory, e.g. foobar
and hhhhhh
the following seems to work as well:
"**/vendor/[^fh]*": true,
"**/vendor/[fh][^oh]*": true,
"**/vendor/[fh][oh][^oh]*": true,
"**/vendor/[fh][oh][oh][^bh]*": true,
"**/vendor/[fh][oh][oh][bh][^ah]*": true,
"**/vendor/[fh][oh][oh][bh][ah][^rh]*": true,
"**/vendor/{foobar?*, hhhhhh?*}": true,
For me, the proposed solution works (e.g. => for gatsby-th*, firstmod*, secondmo*
)
"node_modules/[^gfs]*" : true,
"node_modules/g[^a]*" : true,
"node_modules/ga[^t]*" : true,
"node_modules/gat[^s]*" : true,
"node_modules/gats[^b]*" : true,
"node_modules/gatsb[^y]*" : true,
"node_modules/gatsby[^-]*" : true,
"node_modules/gatsby-[^t]*" : true,
"node_modules/gatsby-t[^h]*" : true,
"node_modules/f[^i]*" : true,
"node_modules/fi[^r]*" : true,
"node_modules/fir[^s]*" : true,
"node_modules/firs[^t]*" : true,
"node_modules/first[^m]*" : true,
"node_modules/firstm[^o]*" : true,
"node_modules/firstmo[^d]*" : true,
"node_modules/s[^e]*" : true,
"node_modules/se[^c]*" : true,
"node_modules/sec[^o]*" : true,
"node_modules/seco[^n]*" : true,
"node_modules/secon[^d]*" : true,
"node_modules/second[^m]*" : true,
"node_modules/secondm[^o]*" : true,
Any progress for this? We really need a simple way to include files or folders.
In our corporation we use huge mono repository. For development we must open root of this repo, but project may use 0.1% of common code base. Our use case — include to search/watch only dirs related to concrete project (0.1%) and ignore other (99.9%)
The ! negate exclude for a glob would turn my excludes lines from about 40 to only about 5.
I ended up here trying to hide all directories in node_modules except those that start with @ or . and while this feature would be immensely useful, this line in files.exclude worked for my use case.
"node_modules/[abcdefghijklmnopqrstuvwxyz]*": true
Is there any update on this? It would be much appreciated! @isidorn
@isidorn @bpasero: If someone were to look at sending a PR for this, is there a direction you'd prefer? (cc @solomatov)
false
(or {"when":"false"}
) in the configFor the large-monorepo use case, supporting this would make it simpler to support focused working-set views into the much larger tree.
I personally prefer adding "files.include" setting, though I think adding "!" or "false" support has better defined conflict resolution, using ordering as the tie-breaker and thus supports more of the use cases described in this issue.
This was frustrating me so I have created a quick and dirty extension that can emulate the desired files.includes
behaviour until this feature is added to VS Code.
To use it:
hide.config.js
file
module.exports = {
ignore: ['.git'], // add any directories you are happy to exclude from the recursive search
keep: ['extension.js', 'commands/**'] // only these files will be available in the Explorer view
}
Hide Config
from the command palette to generate a .hidemyfilesrc
file. Hide Files
, .hidemyfilesrc
will replace the files.exclude
property in .vscode.settings.json
, thus excluding all of the files in your project except for the files and directories you add to the keep
array.hide.config.js
you will have to reload the window and run Hide Config
from the command palette for the changes to take effect (if someone has experience with VS Code extensions and can explain why this is necessary that would be great)<directory name>/**
The documentation linked to the setting mentions the usage of pattern negation syntax using ! . Maybe this should be removed until the feature is implemented?
@isidorn This was linked in the March Iteration plan here https://github.com/microsoft/vscode/issues/92242 but has since dropped off the April Iteration plan. Is this on the back burner for now?
I have been looking forward to this feature as a Unity developer, where we have many folder in the project hierarchy, which could have arbitrary names, but only one folder called "Scripts" where the C# I intend to edit actually lives.
Not currently on the plan. Might be back in May.
It's not just node_modules
. If you open a project like DefinitelyTyped… you're generally only going to be reading / working on a single package under it's types
directory.
Without this feature, how can anyone sanely navigate the 6690 directories within?!
ls -l types | wc -l
6690
(short of opening VSCode directly in the types/<project>
you're interested in).
Until this is implemented, I'm making do with this silly setting:
"types/[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,z]*": true,
Thanks @ArturoDent - this seems to be equivalent:
"types/[^y]*": true,
@sanbox-irl As a workaround you can use this in your settings to show only the scripts
folder:
files.exclude {
"**/[^s]*": true,
"**/s[^c]*": true,
"**/sc[^r]*": true
// more if necessary
}
You can see the pattern - you may need more or fewer entries depending on your other folder names.
frankly, in Unity, I just type the other folders out. I believe that trick has some strange platform issues? It's been at least a year. I think it either doesn't work on Mac or doesn't work on PC? I don't exactly recall. Anyway, I look forward to when the team has a chance to bring the issue forward to more robust solution. Lots of dev going on anyway
With not being able to do this yet. Is there a way to read a separate file hosting the json objects to exclude? I hate to clutter up my workspace with 900 different folders I want to exclude. I mean it works but its annoying :-)
Here's my way to except /node_modules/foo from the exclude,
"files.exclude": { "**/node_modules/{[^f],?[^o],??[^o]}*": true }
thanks, look like this is the best workaround solution I can take from a super looooooong topic!
I want to include Bulma folder ( to work with autocomplete ) and then here is what I set on setting
"files.exclude": {
"**/node_modules/{[^b],?[^u],??[^l],???[^m]}*": true
}
@isidorn I wonder why this ugly old problem has not been resolved yet?
I don't want to spend much time to investigate the script, so I'm using the "Explorer Exclude" extension.
For those like me who want to exclude everything except dotfiles in a workspace folder, right-click the folder in the explorer, click Open Folder Settings and search for "exclude". Then in the Files: Exclude list, add these patterns:
!**/.*
**/[0-9]*
**/[a-z]*
**/[A-Z]*
For those like me who want to exclude everything except dotfiles in a workspace folder, right-click the folder in the explorer, click Open Folder Settings and search for "exclude". Then in the Files: Exclude list, add these patterns:
!**/.* **/[0-9]* **/[a-z]* **/[A-Z]*
Just an extra note that this also excludes files in dotfile directories (e.g. you can't see anything inside the ~/.ssh directory) so a better pattern is:
!**/.*
[0-9]*
[a-z]*
[A-Z]*
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:
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.