6

I have tried vscode.commands.executeCommand('workbench.action.editor.changeLanguageMode', 'JSON');. But it does nothing more than open a panel. And TextDocument.languageId is an readonly property.

2 Answers 2

5

It was implemented at some point (1.28.0+ probably):

vscode.languages.setTextDocumentLanguage(activeEditor.document, languageId);
Sign up to request clarification or add additional context in comments.

Comments

1

Currently this is not possible. Here is the corresponding issue on GitHub. You should upvote (thumbs up) it to tell them we want this.

1 Comment

Looks like that feature is implemented now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.