vscode|July 08, 2019|1 min read

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

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.

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

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…

Server Security Best Practices — Complete Hardening Guide for Production Systems

Server Security Best Practices — Complete Hardening Guide for Production Systems

Every breach post-mortem tells the same story: an unpatched service, a…

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

If you’re a Senior Engineer (L5) preparing for Staff (L6+) roles at MAANG…

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF have been in the OWASP Top 10 for over a decade. They’re among the…

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

The OWASP Top 10 is the industry standard for web application security risks. If…