Problem Statement

I have a drupal module, where there is a file of extension .module, which is a php file. But, Visual Studio code doesn’t understand this as php language. I want to make it understand that it is a php file, and please highlight syntax.

Associate File extensions to language

Open settings json dialog box by pressing: “Control + Shift + P” (On windows), or “Cmd + Shift + P” (On mac). And type: settings json

Visual Studio Code

You will be shown a json file in the editor. Search for files.associations. Note: The searched section might be there or not.

If its not there, simply add following:

Visual Studio Code

i.e. put

"files.associations": {
      "*.module": "php"
}

Or, if you have multiple extensions to put:

"files.associations": {
      "*.module": "php",
      "*.thor": "ruby"
}

Simply save settings file. And, no need to restart the editor.