Change VSCode Default Language for new files?

Now you can do this change. Check out "files.defaultLanguage" in settings.


With v1.42 you can either set

"files.defaultLanguage": "${activeEditorLanguage}"

and when you open a new untitled file with an html file as the last active file, the new file will automatically be assigned a languageMode of HTML.

Alternatively, pasting any html code into a new untitled file from a vscode editor will automatically be detected and the languageMode set to HTML. Unless you have specifically set

"files.defaultLanguage": "plaintext"  

then the languageMode will not be automatically detected as of v1.43.


Also see https://stackoverflow.com/a/68596936/836330 for a preview language detection feature in vscode 1.59.


You can now set the default language at either the user or workspace settings level using files.defaultLanguage:

"files.defaultLanguage": "html"

This can be done as a one off by changing the language mode:

  1. F1 to launch command palette
  2. Type lang, enter
  3. Type html, enter