Is there a way in vscode to enable syntax highlighting without saving the file?

Visual Studio-Code

Visual Studio-Code Problem Overview


Notepad++ has a Language menu which we can use to set the language of the current file without saving it, which provides syntax highlighting. This is useful for quickly checking out things, like, pasting an XML file and quickly analyzing it, typing out some JS code and copying it into a console.

Is there a way to achieve this in vscode?

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

In the lower right corner of the vscode window (next to the tweet feedback smiley face button) is the current language used for the opened file. If you click the current language (defaults to "Plain Text" for me) you will be given an option to select the language for the file. No need to save the file with an extension.

You could also press Ctrl+Shift+P and type "Change Language Mode" to get to the same language prompt

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndrew NessinView Question on Stackoverflow
Solution 1 - Visual Studio-CodealexriedlView Answer on Stackoverflow