23 Oca 2023
by Şerif Çiçek

How do i add file extension in vscode as a certain language

How do i add my self file extension in vscode as a certain language

Visual Studio Code (VS Code) has a built-in feature that allows you to associate a file extension with a specific language. This is called "language mode."

Here are the steps you can follow to associate a file extension with a specific language in VS Code:

  1. Open the file that you want to associate with a specific language in VS Code.
  2. Click on the "Language Mode" button in the lower right corner of the VS Code window. It should say "Plain Text" by default.
  3. Select "Configure File Association for..." from the drop-down menu.
  4. Type the file extension you want to associate with a specific language in the "File Extension" field. For example, ".myext".
  5. Select the language you want to associate with the file extension from the "Language" drop-down menu.
  6. Click on the "Add" button to add the association.

Restart VS Code for the changes to take effect.

Alternatively, you can also make these association by editing the settings.json file, you can do that by going to Preferences: Open User Settings and then add the following to your settings.json


 

"files.associations": {

    "*.phhtml": "php"

}

 

As the second way

1. Press ctrl + shift + p

2. Type and click "Preferences:Open User Settings Json"

3. add the following code


 "intelephense.files.associations": [

       

        "*.php",

        "*.phtml"

    ],

    "files.associations": {

        "*.phhtml": "php"

    },

This way, you can make your own extension behave like your target language in vscode editor with the adjustments you make.


Add Comment
Yorum yazmak için lütfen üye olunuz