Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Visual Studio Code recognize html, php and javascript all in one file?

I started using Visual Studio Code and I have noticed that it recognizes only one language at a time. Is there a way to change that so that I can have 3 recognized languages (HTML, JavaScript, PHP) all in the same .php file?

So I can get colors and snippets and such for all 3 languages at the same time

like image 495
Deweyes Nada Avatar asked Jul 20 '16 23:07

Deweyes Nada


People also ask

How do you align all codes in VS Code?

What is the shortcut key for alignment in Visual Studio Code? On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.

How do I enable auto format in VS Code?

Click the “Settings” gear icon in the bottom-left corner. Search “Formatter” and click the “Editor: Default Formatter” option. From the drop-down menu, select whichever code formatter you want to use. Scroll down a bit and check the box next to the “Editor: Format On Save” option.

How do you autocomplete HTML tags in Visual Studio code?

You can trigger suggestions at any time by pressing Ctrl+Space. You can also control which built-in code completion providers are active. Override these in your user or workspace settings if you prefer not to see the corresponding suggestions.


2 Answers

From vscode 1.20 (Jan 2018) it's possible to create Global snippets:

{
    "check": {
        "scope": "html,javascript,php",
        "prefix": "check",
        "body": [
            "✅"
        ]
    }
}

To make it work in all languages simply omit the "scope"

like image 151
Alex Avatar answered Oct 22 '22 16:10

Alex


Ideally you would use only one of them per file, but using the PHP language the editor supports all these languages.

enter image description here

like image 37
Luís Henrique Faria Avatar answered Oct 22 '22 17:10

Luís Henrique Faria