VSCode 的默认设置文件在什么位置? [英] What is the location of the default settings file of VSCode?

查看:329
本文介绍了VSCode 的默认设置文件在什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 机器上,VS Code 用户设置文件位于 %AppData%\Code\User\settings.json.

On a Windows machine, the VS Code user settings file is located at %AppData%\Code\User\settings.json.

当我们从上述位置打开用户设置文件或转到 文件 -> 时,包含默认设置的文件的位置是什么?首选项 ->设置菜单?

What is the location of the file containing the default settings that show up in the left pane when we open either the user settings file from the location mentioned above or by going to the File -> Preferences -> Settings menu?

%AppData%\Code\User\ 中有一个 storage.json 但看起来不像整个设置.

There is a storage.json in the %AppData%\Code\User\ but that doesn't look like the whole settings.

推荐答案

所有默认设置为只读格式

如果您只想查看所有默认值,请使用命令面板 (Ctrl+Shift+P) 并运行首选项:打开默认设置 (JSON)".VSCode 将生成所有默认值的 JSON 描述.

All defaults in a read-only format

If you just want to see what all the defaults are, use the Command Palette (Ctrl+Shift+P) and run "Preferences: Open Default Settings (JSON)". VSCode will generate a JSON description of all of the defaults.

默认设置是在 vscode 源代码中硬编码.

让我们看一些例子.当我打开设置"时,我看到一长串列表,这是在顶部:

Let's look at some examples. When I open Settings, I see a long list, and this is at the top:

第一个条目是文件:自动保存".这是由 files.contribution.ts:

The first entry is "Files: Auto Save". That is defined by this fragment of Typescript code in files.contribution.ts:

        'files.autoSave': {
            'type': 'string',
            'enum': [AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE],
            'markdownEnumDescriptions': [
                nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.off' }, "A dirty file is never automatically saved."),
                nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.afterDelay' }, "A dirty file is automatically saved after the configured `#files.autoSaveDelay#`."),
                nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onFocusChange' }, "A dirty file is automatically saved when the editor loses focus."),
                nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'files.autoSave.onWindowChange' }, "A dirty file is automatically saved when the window loses focus.")
            ],
            'default': platform.isWeb ? AutoSaveConfiguration.AFTER_DELAY : AutoSaveConfiguration.OFF,
            'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSave' }, "Controls auto save of dirty files. Read more about autosave [here](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save).", AutoSaveConfiguration.OFF, AutoSaveConfiguration.AFTER_DELAY, AutoSaveConfiguration.ON_FOCUS_CHANGE, AutoSaveConfiguration.ON_WINDOW_CHANGE, AutoSaveConfiguration.AFTER_DELAY)
        },

注意 default 值,它顺便取决于 isWeb 变量.由于我在 Windows 上运行 VSCode(其中 isWeb 显然是错误的),我看到默认值为off"对于这个属性.

Notice the default value, which incidentally depends on the isWeb variable. Since I'm running VSCode on Windows (where isWeb is evidently false), I see a default value of "off" for this attribute.

下一个属性是文件:自动保存延迟".碰巧的是,同一文件中的下一个片段包含它:

The next attribute is "Files: Auto Save Delay". As it happens, the very next fragment in the same file contains it:

        'files.autoSaveDelay': {
            'type': 'number',
            'default': 1000,
            'markdownDescription': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'autoSaveDelay' }, "Controls the delay in ms after which a dirty file is saved automatically. Only applies when `#files.autoSave#` is set to `{0}`.", AutoSaveConfiguration.AFTER_DELAY)
        },

同样,GUI 中的默认值 1000 来自此处的 default 属性.

Again, the default value of 1000 in the GUI comes from the default attribute here.

下一个属性是编辑器:字体大小".它来自 commonEditorConfig.ts:

The next attribute is "Editor: Font Size". It comes from commonEditorConfig.ts:

        'editor.fontSize': {
            'type': 'number',
            'default': EDITOR_FONT_DEFAULTS.fontSize,
            'description': nls.localize('fontSize', "Controls the font size in pixels.")
        },

这里,默认值不是文字,所以我们要追踪EDITOR_FONT_DEFAULTS.fontSize的定义.在这里,在 editorOptions.ts:

Here, the default value is not a literal, so we have to track down the definition of EDITOR_FONT_DEFAULTS.fontSize. Here it is, in editorOptions.ts:

export const EDITOR_FONT_DEFAULTS = {
    fontFamily: (
        platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY)
    ),
    fontWeight: 'normal',
    fontSize: (
        platform.isMacintosh ? 12 : 14
    ),
    lineHeight: 0,
    letterSpacing: 0,
};

有趣的是,默认值取决于平台.由于我不是在 Mac 上运行,所以我看到默认值为 14.

It is again interesting that the default depends on the platform. Since I'm not running on Mac, I see a default of 14.

等等.每个默认设置都来自 Typescript 源代码,或者在某些情况下,package.json 扩展文件(内置或由用户安装).

And so on. Each of the default settings comes from Typescript source code or, in some cases, package.json files for extensions (either built-in or installed by the user).

这篇关于VSCode 的默认设置文件在什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆