Note that for "Untitled" editor ("Untitled-1
", "Untitled-2
"), you now can set the language in the settings.
The previous setting was:
"files.associations": {
"untitled-*": "javascript"
}
This will not always work anymore, because with VSCode 1.42 (Q1 2020) will change the title of those untitled editors.
The title will now be the first line of the document for the editor title, along the generic name as part of the description.
It won't start anymore with "untitled-
"
See "Untitled editor improvements"
Regarding the associated language for those "Untitled" editors:
By default, untitled files do not have a specific language mode configured.
VS Code has a setting, files.defaultLanguage
, to configure a default language for untitled files.
With this release, the setting can take a new value {activeEditorLanguage}
that will dynamically use the language mode of the currently active editor instead of a fixed default.
In addition, when you copy and paste text into an untitled editor, VS Code will now automatically change the language mode of the untitled editor if the text was copied from a VS Code editor:
And see workbench.editor.untitled.labelFormat
in VSCode 1.43.
In March 2021 (possible for VSCode 1.55), issue 118455 "Automatic language classification for Untitled files" and PR 119325 are studying some kind of automatic language detection for untitled files.
And if you forget, with VSCode 1.56, Apr. 2021:
We have noticed that many new users are not aware that a language has to be set in order to get full VS Code language support.
To help with this problem, we have introduced a hint for untitled editors to help users set the correct language mode.
The untitled hint might not be helpful to advanced users, so it goes away immediately as you start typing or you can select don't show to never display the hint again.