Xim Bravo Jordana
Xim Bravo Jordana

Reputation: 27

Can a vs code extension change the vs code settings?

I would like to know if I can make an extension that enables "Render Whitespace" to all. I know that you can change it in "File->Preferences->Settings->Render Witespace:all" but my question is that I want that when a user installs my extension this property changes.

enter image description here

It is posible? Thank you

Upvotes: 0

Views: 1238

Answers (1)

Jan Dolejsi
Jan Dolejsi

Reputation: 1528

Your extension code may and can change any settings in the user, workspace or machine scope.

Notice there is a gear icon next to every setting, which lets you copy the setting ID: Setting ID

Copy the ID and use it in this code:

await vscode.workspace.getConfiguration()
    .update('editor.renderWhitespace', 'selection', vscode.ConfigurationTarget.Global);

Here is a full example of how to work with configuration settings: https://github.com/microsoft/vscode-extension-samples/tree/master/configuration-sample

Upvotes: 2

Related Questions