Home > Net >  Restrict languages auto-detected by VSCode?
Restrict languages auto-detected by VSCode?

Time:01-24

Currently, when I paste JSON into a new tab in VSCode, it will usually detect its Language Mode as something else (ex CoffeeScript, etc, etc). Usually these are languages that I never use and don't care about.

Can I restrict the list of possible languages that it auto-identifies, so that it has a better chance of realizing that what I pasted in was JSON?

CodePudding user response:

The description of that setting, Workbench > Editor: Language Detection, says that it can be scoped to restrict which languages it is applied to:

// Controls whether the language in a text editor is automatically detected unless the language has been explicitly set by the language picker. This can also be scoped by language so you can specify which languages you do not want to be switched off of. This is useful for languages like Markdown that often contain other languages that might trick language detection into thinking it's the embedded language and not Markdown.

So you could try this setting (in your settings.json):

"[json, jsonc]": {
  "workbench.editor.languageDetection": false
}

This may only apply to previously set json files so let me know if this makes any difference. I don't think there is any other option other than disabling all language detection - of which I assume you are aware.

  • Related