65

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?

Andrew Nessin
  • 1,206
  • 2
  • 15
  • 22

1 Answers1

139

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

alexriedl
  • 5,916
  • 3
  • 21
  • 17
  • 4
    Just wanted to say that I've been using VS Code for quite some time now, working with many advanced extensions, writing code in various languages, and yet I've managed to disregard this option in the software somehow. So simple, yet so powerful. Thanks!! – TheCuBeMan Jun 19 '18 at 18:48
  • To set a default language mode: Settings -> type "language mode" -> Under: Files: Default Language, type "javascript" (or whatever else you want) – Sv1 Apr 24 '19 at 00:02
  • 1
    feature request: vscode to remember selection – Quang Van Sep 27 '19 at 14:42
  • damn this was so simple yet evaded me for ages, my colleague would laugh at me for using vscode whilst he felt superior with his notepad ++, no more! – Umar.H Feb 03 '20 at 09:00
  • 1
    This is just so cool. Thanks. – Tuan Phan Nov 11 '20 at 01:45