Visual studio скрыть папку
используя код Visual Studio от Microsoft, как скрыть определенные файлы и шаблоны файлов от отображения на боковой панели?
Я хочу, чтобы скрыть .meta и .git файлы типа
- открыть VS Настройки пользователя (главное меню: Файл > Настройки > Настройки). Это откроет экран настройки.
- выполнить поиск файлов:исключить в поиске вверху.
- при необходимости настройте параметры пользователя с помощью новых шаблонов glob. В этом случае добавьте этот шаблон node_modules/ затем нажмите кнопку ОК. синтаксис шаблона является мощным. Вы можете найти шаблон подробности под Поиск файлов по теме.
иногда вы просто хотите, чтобы скрыть определенные типы файлов для конкретного проекта. В этом случае, вы можете создать папку в папке проекта под названием .vscode создать settings.json файл там, (т. е. .vscode/settings.json ). Все настройки в этом файле будут влиять только на текущую рабочую область.
например, в проекте TypeScript, это то, что я использовал:
на .meta файлы при использовании Unity3D я нашел лучший шаблон для скрытия:
это захватывает все папки и подпапки, и забрать foo.cs.meta кроме foo.meta
Я также хотел бы рекомендовать расширение vscode Пип, что позволяет переключать скрыть исключенные файлы в настройках ваших проектов.формат JSON.
нажмите F1 для командной строки vscode (палитра команд), затем
вы можете привязать "расширение.peepToggle " к клавише, как Ctrl + Shift+P (так же, как F1 по умолчанию) для легкого переключения. Нажмите Ctrl + K Ctrl+S для привязки клавиш, введите peep , выберите Peep Toggle и добавьте привязку.
"Сделать Скрытый" расширение работает отлично!
Make Hidden обеспечивает больший контроль над каталогом вашего проекта, включая контекстные меню, которые позволяют легко выполнять действия скрытия/отображения, проводник панели просмотра для просмотра скрытых элементов и возможность сохранять рабочие пространства для быстрого переключения между массовыми скрытыми элементами.
I'm trying to exclude several folders on the Explore tab in Visual Studio Code. To do that, I have added a following jsconfig.json to the root of my project:
But the node_modules folder is still visible in the directory tree.
What am I doing wrong? Are there any other options?
It seems most answers are suggesting to change this configuration in Workspace Settings. However, I don't need node_modules to show up on any project. So I would set it globally in User Settings instead.
9 Answers 9
- Go to File -> Preferences -> Settings (or on Mac Code -> Preferences -> Settings)
- Pick the workspace settings tab
- Add this code to the settings.json file displayed on the right side:
If you chose File -> Preferences -> User Settings then you configure the exclude folders globally for your current user.
Just if somebody wonders: A trailing slash isn't helping (nor harming) in limiting the exclude to Folders only. i.e. "**/BACKUP/": true is just as good/bad as without the last slash.
The value you provide on the RHS appears to be merged with the value on the LHS. Presumably one would have to copy the value from the LHS and set it to false to overwrite the default values.
How does inheritance work here? Do I have to list all excludes or just the ones not listed in user settings?
It's worth noting that in the current version of Code (1.28.2), the files.exclude key belongs inside the settings key of the code-workspace file.
In newer versions of VS Code, you navigate to settings ( Ctrl + , ), and make sure to select Workspace Settings at the top right.
Then add a files.exclude option to specify patterns to exclude.
You can also add search.exclude if you only want to exclude a file from search results, and not from the folder explorer.
Exclude from search while still being able to browse files in the explorer - exactly what I needed, thanks!
I had to place files.exclude inside settings: < . >when applying it to the workspace settings (.code-workspace file) otherwise it complained on the lines of the property being unknown. There was a third "Folder settings" tab (.vscode/settings.json) in which it worked in the outermost braces.
GUI way
- Go to "File -> Preferences -> Settings" (or press Ctrl + , ) then:
- Type "exclude" to the search bar.
- Select the "Workspace" tab if you want this change to only effect your current project instead of each one.
- Click the "Add Pattern" button.
Code way
To open the settings.json file:
- Press Ctrl + Shift + P or Cmd + Shift + P on Mac, then type "Open Workspace Settings (JSON)".
- OR, on older versions you can click the little <> icon at the top right corner of the GUI tab:
Add excluded folders to files.exclude . Also check out search.exclude and files.watcherExclude as they might be useful too. This snippet contains their explanations and defaults:
For more details on the other settings, see the official settings.json reference.
Using Microsoft's Visual Studio Code, how do I hide certain files and file patterns from appearing in the sidebar?
I want to hide .meta and .git style files
It's not exactly what you need, but you can at least exclude certain folders from searches by adding a "search.excludeFolders" property to your workspace settings. This was enough for me since I usually reach files by the Ctrl-E menu.
12 Answers 12
You can configure patterns to hide files and folders from the explorer and searches.
- Open VS User Settings (Main menu: File > Preferences > Settings ). This will open the setting screen.
- Search for files:exclude in the search at the top.
- Configure the User Setting with new glob patterns as needed. In this case add this pattern node_modules/ then click OK. The pattern syntax is powerful. You can find pattern matching details under the Search Across Files topic.
When you are done it should look something like this:
If you want to directly edit the settings file: For example to hide a top level node_modules folder in your workspace:
To hide all files that start with ._ such as ._.DS_Store files found on OSX:
You also have the ability to change Workspace Settings (Main menu: File > Preferences > Workspace Settings ). Workspace settings will create a .vscode/settings.json file in your current workspace and will only be applied to that workspace. User Settings will be applied globally to any instance of VS Code you open, but they won't override Workspace Settings if present. Read more on customizing User and Workspace Settings.
In the later VSCode versions (Nov 2017) you use File>Preferences>Settings and use the dropdown on top right to select UserSettings or Workspace. Selecting Workspace will then create the .vscode folder and settings.json in your project
Sometimes you just want to hide certain file types for a specific project. In that case, you can create a folder in your project folder called .vscode and create the settings.json file in there, (i.e. .vscode/settings.json ). All settings within that file will affect your current workspace only.
For example, in a TypeScript project, this is what I have used:
VS Code now has a tab when you go to Preferences > Settings where you can switch between User Settings and Workspace Settings, so you don't have to manually create the file yourself anymore. Great example on excluding file types--thanks!
The "Make Hidden" extension works great!
Make Hidden provides more control over your project's directory by enabling context menus that allow you to perform hide/show actions effortlessly, a view pane explorer to see hidden items and the ability to save workspaces to quickly toggle between bulk hidden items.
Imho, this is the best answer if you are looking to just hide files/folders in the directory tree without side affects such as affecting search or go to file
Sadly it no longer works. I suspect it's more a problem with vscode's instability than the extension developer.
The __pycache__ folder and *.pyc files are totally unnecessary to the developer. To hide these files from the explorer view, we need to edit the settings.json for VSCode. Add the folder and the files as shown below:
I would also like to recommend vscode extension Peep, which allows you to toggle hide on the excluded files in your projects settings.json.
Hit F1 for vscode command line (command palette), then
You can bind "extension.peepToggle" to a key like Ctrl + Shift + P (same as F1 by default) for easy toggling. Hit Ctrl + K Ctrl + S for key bindings, enter peep , select Peep Toggle and add your binding.
For .meta files while using Unity3D, I found the best pattern for hiding is:
This captures all folders and subfolders, and will pick up foo.cs.meta in addition to foo.meta
It works, but then the global search stops working with error: Error parsing glob . invalid use of **; must be one path component , should be "*/**/*.meta": true
If you're using VSCode:
- File > Preferences > Settings
- Search for:
You shouldn't need to restart or reload VSCode to take effect
If your working on a Angular 2+ application, and like me you like a clean working environment, follow @omt66 answer and paste the below in your settings.json file. I recommend you do this once all the initial setup has been completed.
Note: This will actually hide the .vscode folder (with settings.json) in as well. (Open in your native file explorer / text editor if you need to make changes afterwards)
VS Code's File Nesting Feature
See the GIF below
I answered this question, with File-nesting as an answer a month or two ago, however, the feature wasn't actually released yet, but today the "VS Code File Nesting Feature" released officially.
It's one of the cooler features released in the past 6 months or so, for sure. I took the time to create a gif, which shows the configuration I used to get the functionality that the gif demonstrates. Ill also go over each available setting.
The GIF you see below shows File-Nesting, and How it works.
The gif shows a folding control that is able to toggle files in & out of view (one might say that it hides them, which would be an accurate statement). However, it does this without a directory. The question at this point is HOW? How does it know which to hide?
File-nesting has to be configured. You got to add the settings you see in my settings.json file on the right side of the GIF, but before you go watch the GIF again, lets go over each file nesting setting below.
Available Configurations
The following excerpts were taken straight from the release notes for the "VS Code April 2022 release"
explorer.fileNesting.enabled
- Controls whether file nesting is enabled at-large. It can be set either globally or for a specific workspace.
explorer.fileNesting.expand
- Controls whether nested files are expanded by default.
explorer.fileNesting.patterns
- Controls how files are nested. The default configuration provides nesting intelligence for TypeScript and JavaScript projects, but you're encouraged to modify this to fit your own project's structure. Some examples:
The most important setting is explorer.fileNesting.patterns
. because it is the setting you use to define how to nest your files. When you enter it into your settings.json configuration file, VSCode automatically suggests a configuration, and you should definitely roll with that suggestion and add it to your configuration file, if not for any other reason than the fact; it is a great example for showing how to use this feature. The Gif shows some of the configurations I have been toying with, but I will post them below, so you can see the actual text for the configuration.
I highly suggest keeping your "File-nesting" Configuration(s) on a workspace to workspace level.
I find that I am always in and out of my settings.json file if I try to use the file-nesting feature &/or the "files.exlude" setting in my global (or user-scoped) settings.json file.
Also, as cool as file-nesting is, it doesn't replace "files.exclude" it compliments it, and quite well might I add.
Below is the default configuration I use for ESM NodeJS TypeScript projects, which is what most of my projects are. The configuration is generic, and changes from project to project.
If you like to emit your compiler's (or transpiler's) output inline with your source-documents, then this feature is ten times more valuable to you. I always work out of the standard compiled-language file-structure where there is a root directory that has a source directory, and an out directory, so I don't ever emit JS into my TS, but if you do, this feature will allow you to nest the JS/TS file pairs. Or if you write C/C++ you can nest your *.o files with your *.c files.
Its just a great way of hiding files, in a way that consolidates everything, while keeping it very accessible.
Is it possible to hide folder in Visual Studio 2012 solution explorer window? I have multiple folders/files that I don't plan to use and they are just cluttering the interface and it's harder to find things.
It just seems pretty illogical that you can toggle "Show Hidden Files" but you cannot actually hide any files.
WebApi project includes automated help generation that I want to use, however it includes multiple folders that it needs to function. All I care about is Controllers/Models since I'm building the Api itself. But if I delete/remove from project those files than help generator won't work.
4 Answers 4
Since you want the files to still be accessible, as opposed to just excluding them, you can modify the csproj file itself. Unload your project from the solution, right-click and select edit. Scroll down to where your folders are displayed (I tested with a folder called "TestFolder" and a file within it called TestClass.cs .
Create a new child tag called Visible and set the value to false .
Save and reload the project and the files should no longer be visible but accessible. I just did a quick test and it seemed to work fine (but YMMV).
Hmm, I'm not too sure. This is a bit of a hack so there might be a better way of doing it but I can't seem to get an entire folder to be hidden (without resorting to adding tags for each item) :/
I know I'm a bit late to the party, but here's a similar solution I just found. I wanted to target all files in all directories inside my "x64" folder (and also hide them. So I used this for the path: "x64***"
Hiding folders is almost certainly a bad idea. Remember that hiding a folder is not the same as excluding it from the solution - all hidden items can still be used elsewhere in the code, can be referenced by the build, and get updated when you pull the latest version from source control.
That is the reason why it was never available for project folders - so that people cannot easily confuse their workmates.
Having said that, it is possible to hide folders on the solution level - I guess mostly because it's quite common to have documentation, shared libraries etc on that level. To hide a solution folder, you right click on the folder, and select "Hide Folder" (to unhide, you'd right click on the solution itself and select "Unhide folders")
As for your screenshot where you want to hide Area , Scripts etc - I suspect you're working alone and just started learning MVC - otherwise it wouldn't make sense to hide those folders. They contain legitimate code which is used to run the application. Hiding it is the same as hiding Program.cs in a console project for the sole reason that you prefer a smaller tree in the solution.
I do agree that Solution Explorer becomes unmanageable at some point - but instead of messing up with it, I'd recommend to try other tools - Visual Studio "navigate to" options or Resharper (I use the latter).
report this ad
This article shows you 2 ways to hide some specific files/folders from the left-hand file explorer in VS Code (Visual Studio Code). The first approach is to use the GUI (graphic user interface) and the second one to create a file named settings.json.
Using GUI
1. Go to the “Settings” page:
- Windows: File > Preferences > Settings (hotkeys: Ctrl + ,)
- Mac: Code > Preferences > Settings (shortcuts: Command + ,)
2. Type “files:exclude” into the search field then head to the “Files: Exclude” section that appears as the search result. (If you want to make changes for just a single project, select the “Workspace” tab instead of the “User” tab).
3. Click on the “Add Pattern” button and declare the file types or folders you want to hide. For example: **.lock, **.txt, node_modules, etc.
Manually create a settings.json file
Create a folder named .vscode and in the root directory of your project then create a file named settings.json inside that folder (the names are mandatory).
List the patterns of files and folders you want to hide. For example:
Final Words
We’ve gone through a couple of different ways to dismiss some files/folders from the left file-explorer in VS Code. If you want to discover more things in VS Code, take a look at the following articles:
If you have any questions, feel free to leave a comment. I will do my best to help.
Читайте также: