Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make Visual Studio Code recognize HTML syntax in PHP files

Tags:

I am using Visual Studio Code on a Mac to work on WordPress applications.

Is there a way to make Visual Studio Code recognize HTML and use it's features (mainly autocompletion) inside PHP files?

I've searched for this answer before but just get told to Go to Visual Studio Code Settings: File >> Preferences >> User Settings

// Place your settings in this file to overwrite the default settings {                 // Configure file associations to languages (e.g. "*.extension": "html"). These have precedence over the default associations of the languages installed.      "files.associations": {"*.php": "html"}       } 

But doing this makes you lose all PHP support and autocompletion.

I wish Microsoft would realize that PHP developers commonly use PHP and HTML together when creating applications/websites. I would love to use VS Code instead of the magnificent but expensive PHP storm if possible.

like image 276
thatemployee Avatar asked Aug 29 '17 20:08

thatemployee


2 Answers

As far as I can tell, it does. Take a look at this php file I have created in VS Code (no extensions), with HTML inside the file with syntax highlighting for both languages. enter image description here

There is a button (It should say the word PHP) in the bottom right corner of the screen that allows you to switch the syntax highlighting and autocompletion to another language, and while this does temporarily turn off PHP syntax, it will allow you to code in HTML a lot easier.

like image 127
Jodast Avatar answered Sep 21 '22 10:09

Jodast


You can install this plugin intellisense-plugin

like image 34
Saket89 Avatar answered Sep 21 '22 10:09

Saket89