vscode1 Min Read

Visual Studio Code - How to associate file extension to a known programming language

Gorav Singal

July 08, 2019

TL;DR

Use the files.associations setting in VS Code's settings.json to map custom file extensions (e.g., .module) to a language like PHP for proper syntax highlighting.

Visual Studio Code - How to associate file extension to a known programming language

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.

Share

Related Posts

VS-Code - How to Debug and pass Command Line Arguments via Launch Config

VS-Code - How to Debug and pass Command Line Arguments via Launch Config

Introduction In this post, I will take example for Python project. And how we…

VS-Code - How to put vscode executable in system path and how to open source code directly in vscode

VS-Code - How to put vscode executable in system path and how to open source code directly in vscode

Introduction VS code is an excellent free IDE for maany types of programming…

Microsoft Visual Studio Code - Must-have extensions for Developers

Microsoft Visual Studio Code - Must-have extensions for Developers

Visual Studio Code is one of the awesome developer tools by Microsoft. Let’s…

How to solve java issue - could not load main class - Visual Studio Code

How to solve java issue - could not load main class - Visual Studio Code

Assuming you have a java project and is using Visual Studio Code as IDE. All of…

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Most developers use Claude Code like a search engine — ask a question, get an…

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Every office lobby has the same problem: a visitor walks in, nobody’s at the…

Latest Posts

Supply Chain Security — Protecting Your Software Pipeline

Supply Chain Security — Protecting Your Software Pipeline

In 2024, a single malicious contributor nearly compromised every Linux system on…

Security Ticketing and Incident Response

Security Ticketing and Incident Response

The worst time to figure out your incident response process is during an…

Security Mindset for Engineers — Think Like an Attacker

Security Mindset for Engineers — Think Like an Attacker

Most engineers think about security the way they think about flossing — they…

Secrets Management — Vault, SSM, and Secrets Manager

Secrets Management — Vault, SSM, and Secrets Manager

I’ve watched a production database get wiped because someone committed a root…

Penetration Testing Basics for Developers

Penetration Testing Basics for Developers

Most developers think of penetration testing as something a separate security…

OWASP Top 10 for Cloud Applications

OWASP Top 10 for Cloud Applications

The OWASP Top 10 was written for traditional web applications. But in the cloud…