How to make VS Code to treat other file extensions as certain language?

John Deev picture John Deev · Apr 30, 2015 · Viewed 123.4k times · Source

Or is there a way to switch the current file's language to use syntax highlight feature?

For example, *.jsx actually uses JavaScript but VS Code doesn't recognize it.

Answer

Josien picture Josien · Apr 22, 2016

In Visual Studio Code, you can add persistent file associations for language highlighting to your settings.json file like this:

// Place your settings in this file to overwrite the default settings
{
  "some_setting": custom_value,
  ...

  "files.associations": {
    "*.thor": "ruby",
    "*.jsx": "javascript",
    "Jenkinsfile*": "groovy"
  }
}

You can use Ctrl+Shift+p and then type settings JSON. Choose Preferences: Open Settings (JSON) to open your settings.json.

The Files: Associations feature was first introduced in Visual Studio Code version 1.0 (March 2016). Check the available wildcard patterns in the release notes and the known language strings in the documentation.