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\
I have followed a different approach to solve pretty much the same problem, in my case, I made a new extension that adds PHP syntax highlighting support for Drupal-specific files (such as .module and .inc): https://github.com/mastazi/VS-code-drupal
As you can see in the code, I created a new extension rather than modifying the existing PHP extension. Obviously I declare a dependency on the PHP extension in the Drupal extension.
The advantage of doing it this way is that if there is an update to the PHP extension, my custom support for Drupal doesn't get lost in the update process.
The easiest way I've found for a global association is simply to ctrl+k m (or ctrl+shift+p and type "change language mode") with a file of the type you're associating open.
In the first selections will be "Configure File Association for 'x' " (whatever file type - see image attached) Selecting this makes the filetype association permanent
This may have changed (probably did) since the original question and accepted answer (and I don't know when it changed) but it's so much easier than the manual editing steps in the accepted and some of the other answers, and totaly avoids having to muss with IDs that may not be obvious.
Hold down Ctrl+Shift+P (or cmd on Mac), select "Change Language Mode" and there it is.
But I still can't find a way to make VS Code recognized files with specific extension as some certain language.
I found solution here: https://code.visualstudio.com/docs/customization/colorizer
Go to VS_CODE_FOLDER/resources/app/extensions/
and there update package.json
Following the steps on https://code.visualstudio.com/docs/customization/colorizer#_common-questions worked well for me:
To extend an existing colorizer, you would create a simple package.json in a new folder under .vscode/extensions and provide the extensionDependencies attribute specifying the customization you want to add to. In the example below, an extension .mmd is added to the markdown colorizer. Note that not only must the extensionDependency name match the customization but also the language id must match the language id of the colorizer you are extending.
{
"name": "MyMarkdown",
"version": "0.0.1",
"engines": {
"vscode": "0.10.x"
},
"publisher": "none",
"extensionDependencies": [
"markdown"
],
"contributes": {
"languages": [{
"id": "markdown",
"aliases": ["mmd"],
"extensions": [".mmd"]
}]
}
}
This, for example, will make files ending in .variables
and .overrides
being treated just like any other LESS file. In terms of code coloring, in terms of (auto) formatting. Define in user settings or project settings, as you like.
(Semantic UI uses these weird extensions, in case you wonder)