Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In a VS Code extension, is there a way to set the configuration options for the editor (such as word wrap) programmatically?

For an extension I am working on, our end-users would prefer to have options such as word-wrap on by default. We would like to be able to set this at the language level without the user's direct involvement (just for the languages our extension is active for). I am aware of the per language settings. My goal is to set settings such as the following:

"[xml]": {
    "editor.wordWrap": "on",
    "editor.tabSize": 4
  },

without the user have to do so in their own user settings. Is there a way to do this via the Extension API? I am not seeing any obvious ways to do so.

PS The LanguageConfiguration object does not seem to be relevant for setting things like word-wrap.

like image 677
augb Avatar asked Jun 27 '17 21:06

augb


1 Answers

Yes, extensions can contribute default editor settings for a language using configurationDefaults in the package.json

Here's what the builtin markdown extension contributes for example:

{
    "name": "vscode-markdown",
    ...,
    "contributes": {
        "configurationDefaults": {
            "[markdown]": {
                "editor.wordWrap": "on",
                "editor.quickSuggestions": false
            }
        }
    }
}

This currently only supports editor.* language specific settings. We are tracking support for contributing additional language specific settings here

like image 148
Matt Bierner Avatar answered Nov 15 '22 07:11

Matt Bierner