如何在Visual Studio代碼中隱藏側欄中的某些文件?

本文翻譯自:How do I hide certain files from the sidebar in Visual Studio Code?

Using Microsoft's Visual Studio Code, how do I hide certain files and file patterns from appearing in the sidebar? 使用Microsoft的Visual Studio代碼,如何隱藏側邊欄中顯示的某些文件和文件模式?

I want to hide .meta and .git style files 我想隱藏.meta.git樣式文件


#1樓

參考:https://stackoom.com/question/22Soq/如何在Visual-Studio代碼中隱藏側欄中的某些文件


#2樓

You can configure patterns to hide files and folders from the explorer and searches. 您可以配置模式以從資源管理器和搜索中隱藏文件和文件夾。

  1. Open VS User Settings (Main menu: File > Preferences > Settings). 打開VS用戶設置(主菜單:文件>首選項>設置)。 This will open the setting screen. 這將打開設置屏幕。
  2. Search for files:exclude in the search at the top. 搜索文件:在頂部的搜索中排除。
  3. Configure the User Setting with new glob patterns as needed. 根據需要使用新的glob模式配置用戶設置。 In this case add this pattern node_modules/ then click OK. 在這種情況下,添加此模式node_modules/然後單擊“確定”。 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: 如果要直接編輯設置文件:例如,要隱藏工作區中的頂級node_modules文件夾:

"files.exclude": {
    "node_modules/": true
}

To hide all files that start with ._ such as ._.DS_Store files found on OSX: 要隱藏所有以._開頭的文件,例如在OSX上找到的._。DS_Store文件:

"files.exclude": {
    "**/._*": true
}

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. 工作區設置將在當前工作空間中創建.vscode/settings.json文件,並且僅應用於該工作空間。 User Settings will be applied globally to any instance of VS Code you open, but they won't override Workspace Settings if present. 用戶設置將全局應用於您打開的任何VS代碼實例,但如果存在,它們將不會覆蓋工作區設置。 Read more on customizing User and Workspace Settings . 閱讀有關自定義用戶和工作區設置的更多信息


#3樓

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, (ie .vscode/settings.json ). 在這種情況下,您可以在項目文件夾中創建一個名爲.vscode的文件夾,並在其中創建settings.json文件(即.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: 例如,在TypeScript項目中,這是我使用的:

// Workspace settings
{
    // The following will hide the js and map files in the editor
    "files.exclude": {
        "**/*.js": true,
        "**/*.map": true
    }
}

#4樓

I would also like to recommend vscode extension Peep , which allows you to toggle hide on the excluded files in your projects settings.json. 我還想推薦使用vscode擴展Peep ,它允許您在項目settings.json中的被排除文件上切換隱藏。

Hit F1 for vscode command line (command palette), then 然後按F1鍵查看vscode命令行(命令調色板)

ext install [enter] peep [enter]

You can bind "extension.peepToggle" to a key like Ctrl+Shift+P (same as F1 by default) for easy toggling. 您可以將“extension.peepToggle”綁定到一個鍵,如Ctrl + Shift + P(默認情況下與F1相同),以便輕鬆切換。 Hit Ctrl+K Ctrl+S for key bindings, enter peep , select Peep Toggle and add your binding. 按Ctrl + K Ctrl + S進行鍵綁定,輸入peep ,選擇Peep Toggle並添加綁定。


#5樓

For .meta files while using Unity3D, I found the best pattern for hiding is: 對於使用Unity3D時的.meta文件,我發現隱藏的最佳模式是:

"files.exclude": {
  "*/**/**.meta": true
}

This captures all folders and subfolders, and will pick up foo.cs.meta in addition to foo.meta 這捕獲所有文件夾和子文件夾,並會拿起foo.cs.meta除了foo.meta


#6樓

The " Make Hidden " extension works great! Make Hidden ”擴展功能非常棒!

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. 通過啓用允許您輕鬆執行隱藏/顯示操作的上下文菜單,使用視圖窗格瀏覽器查看隱藏項目以及保存工作區以在批量隱藏項目之間快速切換的功能,“隱藏”可以更好地控制項目目錄。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章