问题
└── target
├── W350
├── W400
├── W600
├── W600_HW_V2
├── W600_KT_HW_V2
├── W600_KT_HW_V2_neutral
├── W600_TK
├── W650
├── W650_HW_V2
└── W750
I want to exclude all folders except W600_KT_HW_V2
. VSCode should then show this tree:
└── target
└── W600_KT_HW_V2
What should I do?
回答1:
In general, you could do this:
"files.exclude": {
// "**/node_modules": true,
"**/[^1]*": true, // all you need in your example
"**/1[^2]*": true,
"**/12[^3]*": true
},
In your case, only the first "**/[^1]*": true,
would be needed. The additional lines would be used if you had folders like 1abc
that you also want excluded. How deep you go depends on the similarity of your folder names. But you don't give a lot of detail on how complicated your use case is.
But you see the pattern. Vscode doesn't support !
negation in files.exclude
so you have to exclude everything but what you want with the [^x]
form.
After you updated your file structure, it looks like this works:
"files.exclude": {
"**/[^W]*": true,
"**/W[^6]*": true,
"**/W6[^0]*": true,
"**/W600": true, // the only one I had to "hardcode"
"**/W600_[^K]*": true,
"**/W600_KT_HW_V2_*": true
}
which isn't too bad considering how similar the only folder you want is to those to be excluded. You can see the general pattern in the two examples - I was able to eliminate a few of the intermediates after similar folders were excluded earlier.
Also see How to exclude all but certain files in the sidebar in Visual Studio Code? for doing this with file extensions.
来源:https://stackoverflow.com/questions/60565855/how-to-exclude-all-folders-except-one-folder-in-vscode