If i Shift + Alt + F (or use the command from the palette) on a Untitled tab on vscode the following command appear:
There is no formatter for 'plaintext' files installed.
Is there any way to specify a different format for the unsaved file to enable the formatter of choice? This need usually arise when I usually copy/paste some json/xml.
In the latest VS Code (v1.47):
The detected file type is printed on the lower bar of the window, and by default it'll likely say Plain Text for new, unsaved, files.
Click on Plain Text , that'll bring up a box where you can select other formats VS Code knows about. Select the one you want or start typing what you want in the search, such as JSON , and that'll convert the detected file-type over.
Now you can use the standard Format Document command from the command palette, so long as VS Code has a formatter for that file-type.
UPDATE 2 Now the new tab shows directly a selection mode that says:
Select a language to get started. Start typing to dismiss, or don't show this again.
So you just need to press Select a language
UPDATE 1
In the bottom right corner is available the Select Language Mode functionality that now let you select a formatting option, the default one is Plain Text . The same functionality can be used with Ctrl + K M or by selecting Change Language Mode from the command palette.
OLD ANSWER
I found two solutions to this specific problem, even if they seems more a workaround than a proper solution:
Install specific extension that add language specific commands:
Add a configuration to settings.json that specify json as the type of document for untitled files:
"files.associations":