无法编辑默认 VSCode JSON 设置

Cannot Edit Default VSCode JSON Settings

我在 Windows 10 上使用 VSCode 1.47.3。我无法在 json 中编辑默认设置:

  1. 打开默认设置(“文件 -> 首选项 -> 设置”)
  2. 输入默认设置 json 文件进行编辑。
  3. Window 出现“无法在只读编辑器中编辑”

我试过以管理员身份打开VSCode,卸载并重新安装,重新启动我的电脑,降级到1.46,但仍然无法编辑。有人知道如何解决这个问题吗?

vscode 中的默认设置是不可编辑的文档。它是您查看本机设置的默认设置以及扩展程序默认设置的一种方式。

当使用 settings editor:

时,这些默认值还用于识别何时使用 'blue' 行指示器更改设置

Changes to settings are reloaded by VS Code as you change them. Modified settings are now indicated with a blue line similar to modified lines in the editor. The gear icon opens a context menu with options to reset the setting to its default value as well as copy setting as JSON.

目前,vscode 仅提供 2 种可编辑设置:

VS Code provides two different scopes for settings:

  • User Settings - Settings that apply globally to any instance of VS Code you open.
  • Workspace Settings - Settings stored inside your workspace and only apply when the workspace is opened.

Workspace settings override user settings. Workspace settings are specific to a project and can be shared across developers on a project.

Note: A VS Code "workspace" is usually just your project root folder. Workspace settings as well as debugging and task configurations are stored at the root in a .vscode folder. You can also have more than one root folder in a VS Code workspace through a feature called Multi-root workspaces.

您可以使用设置编辑器配置这些设置,如上图所示,或者您可以导航到它们的 JSON 对应项以进行手动输入(如下右图所示)。

对于工作区设置JSON,JSON文件位于根目录下一个名为.vscode的文件夹中,如果没有可以自行创建。

默认情况下,VS Code 显示设置编辑器,但您仍然可以通过使用 command palette 中的打开设置 (JSON) 命令或通过使用 workbench.settings.editor 设置更改默认设置编辑器。


设置

您可以使用以下设置定义显示哪个视图:

  • workbench.settings.openDefaultSettings

    Opens the default settings any time you open regular settings (this only works with the JSON settings editor option)

  • workbench.settings.editor

    Determine which editor to use, you can elect UI or JSON

  • workbench.settings.useSplitJSON

    This will open a JSON settings editor, with the default settings to the left, but the default editor to the left will behave like a UI editor in that you can collapse regions based on category and there is a search input box and it will share the same tab as the json editor on the right, whereas the workbench.settings.openDefaultSettings option mentioned above puts each setting view in its own respective tab (editor)

我遇到了同样的问题,下面是有效的解决方案。确实无法修改默认设置,但以下步骤说明了如何在 JSON:

中编辑设置
  1. Cmd+Shift+P 和 select 打开设置 UI(Ctrl+Shift+P 我认为 Windows)
  2. 通过输入“设置”进行搜索,然后在菜单下 Workbench 设置编辑器 并从 ui 更改为 json
  3. 搜索“使用拆分JSON”并勾选“控制是否使用拆分 JSON…”。

感谢 Ahmad Awais 发布的视频 here

如果您想更改全局设置,您需要通过将 json 添加到 settings.json

来覆盖 defaultSettings.json 文件

按:Ctrl/cmd-shift-p

类型:settings.json

Select:首选项:打开settings.json

请记住,工作区设置仍将覆盖全局设置。