Water Cooler v2
Water Cooler v2

Reputation: 33880

What is the location of the default settings file of VSCode?

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?

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

Upvotes: 15

Views: 20276

Answers (4)

Scott McPeak
Scott McPeak

Reputation: 12933

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.

Where the defaults come from

The default settings are hardcoded in the vscode sources.

Details

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

Screenshot of top of Settings GUI

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)
        },

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)
        },

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

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.")
        },

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,
};

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

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).

Upvotes: 5

Psionman
Psionman

Reputation: 3719

As @Scott McPeak pointed out the defaults are not stored, however if you override any value the overrides are stored on a *nix system in:

~/.config/Code/User

Upvotes: 5

Asif
Asif

Reputation: 87

you can find the default settings for user C:\Users\yourusername\AppData\Roaming\Code\User

Upvotes: 4

hruvulum
hruvulum

Reputation: 105

The list of default settings is not stored in a single file: it is generated when you ask for it.

(It makes sense to generate it every time the user asks for it because it might have changed since the last time the user asked for it because an extension might have been installed or uninstalled: the list includes settings specific to an extension.)

It might be that your reason for asking is because you want a way to view the list without splitting the editor. (That was my reason for doing the web search that led me to this page.) That can be achieved by running the command "Preferences: Open Default Settings (JSON)".

Upvotes: 2

Related Questions