supe345
supe345

Reputation: 141

Can I set VSCode as default editor for specific file type through extension?

I am currently developing a VSCode extension in javascript for a specific type of files. I would like to add a functionality that when opening this file type, the extension will check if the default editor of the file type is VSCode and if not this message will appear:
enter image description here

And then if the user clicks on Open with VSCode, the extension will set VSCode as the default editor of this type of files.

I searched on the VS Code API but I didn't find something useful and I have no clue how I could do something like that.

Thank you very much in advance!

Upvotes: 4

Views: 1496

Answers (1)

Innomight
Innomight

Reputation: 556

You have to interact with the OS to set the defaults. For example - you can go in settings - apps - default apps to set the default apps for specific file types. So I think you cannot do it directly as it also requires admin privileges and you can try using automation or something like that to achieve this. I don't think anyone can provide a direct way or code to do what you mentioned.

Upvotes: 2

Related Questions