简体   繁体   English

如何更改 Visual Studio 代码设置

[英]How to change visual studio code settings

I am trying to changes visual studio code settings.json but it is not working.我正在尝试更改 Visual Studio 代码 settings.json 但它不起作用。 I have updated this in C:\\Users\\Userid\\AppData\\Roaming\\Code\\User\\settings.json but not working.我已经在 C:\\Users\\Userid\\AppData\\Roaming\\Code\\User\\settings.json 中更新了它,但没有工作。 How to edit settings.json file in vs code?如何在 vs 代码中编辑 settings.json 文件?

{
    "css.experimental.customData": ["./css.json"],
    "json.schemas": [ 
        {
            "fileMatch": ["/css.json"],
            "url": "https://raw.githubusercontent.com/Microsoft/vscode-css-languageservice/master/docs/customData.schema.json"
        }
    ]
}

VSCode's settings are split into 2 categories: User and Workspace. VSCode 的设置分为两类:用户和工作区。

User settings用户设置

Settings that apply globally to any instance of VS Code you open.全局适用于您打开的任何 VS Code 实例的设置。

You can edit these settings by pressing ctrl + , It should open to the User Settings tab.您可以通过按ctrl + 来编辑这些设置它应该会打开“用户设置”选项卡。 If it doesn't, click the User Settings tab to edit user settings.如果没有,请单击“用户设置”选项卡以编辑用户设置。 Note that these settings will affect all projects that you open using VSCode.请注意,这些设置将影响您使用 VSCode 打开的所有项目。

VSCode 设置窗格,其中打开了“用户设置”选项卡 VSCode settings pane with User Settings tab open VSCode 设置窗格,其中打开了“用户设置”选项卡

Editing JSON schemas编辑 JSON 模式

The VSCode settings page does not allow direct editing of JSON Schemas. VSCode 设置页面不允许直接编辑 JSON 架构。 To edit JSON schema settings: 1. Search JSON schemas in the VSCode settings page 2. Click "edit in settings.json" 3. Edit settings 4. Done!要编辑 JSON 架构设置: 1. 在 VSCode 设置页面中搜索 JSON 架构 2. 单击“在 settings.json 中编辑” 3. 编辑设置 4. 完成!

编辑 json 架构 JSON schema setting in VSCode VSCode 中的 JSON 模式设置

Workspace settings工作区设置

Settings stored inside your workspace and only apply when the workspace is opened.设置存储在您的工作区中,并且仅在工作区打开时应用。
Workspace settings override user settings.工作区设置会覆盖用户设置。

To edit workspace settings, follow steps for user settings, except click the Workspace Settings tab instead.要编辑工作区设置,请按照用户设置的步骤操作,除非改为单击工作区设置选项卡。 Note that workspace settings will override user settings请注意,工作区设置将覆盖用户设置

css.experimental.customData

You should put your css.json file in .vscode.你应该把你的 css.json 文件放在 .vscode 中。

projectRoot/.vscode/css.json

{
  "version": 1,
  "pseudoElements": [
    { "name": "::bar", "description": "Foo pseudo elements" }
  ]
}

projectRoot/.vscode/settings.json

{
  "css.experimental.customData": ["./.vscode/css.json"],
  "json.schemas": [{
    {
      "fileMatch": ["css.json"],
      "url": "https://raw.githubusercontent.com/Microsoft/vscode-css-languageservice/master/docs/customData.schema.json"
    }
  ]
}

Note: a reload is required to apply changes after editing css.json.注意:编辑 css.json 后需要重新加载才能应用更改。

You can also apply the above instructions for html.json您也可以将上述说明应用于 html.json

Add a folder called ".vscode" in your project and a settings.json in there.在您的项目中添加一个名为“.vscode”的文件夹,并在其中添加一个 settings.json。 Tho keep in mind those settings are project specific请记住,这些设置是特定于项目的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM