有没有办法使Visual Studio代码识别PHP文件中的HTML语法

问题描述 投票:11回答:1

我在Mac上使用Visual Studio Code来处理WordPress应用程序。

有没有办法让Visual Studio代码识别HTML并在PHP文件中使用它的功能(主要是自动完成)?

我之前搜索过这个答案但只是被告知要转到Visual Studio代码设置: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"}     
 }

但这样做会让您失去所有PHP支持和自动完成功能。

我希望微软能够意识到PHP开发人员在创建应用程序/网站时通常会同时使用PHP和HTML。如果可能的话,我很乐意使用VS Code而不是华丽但昂贵的PHP风暴。

php html autocomplete visual-studio-code
1个回答
2
投票

据我所知,确实如此。看看我在VS Code中创建的这个php文件(没有扩展名),文件中包含HTML,两种语言都有语法高亮显示。 enter image description here

屏幕右下角有一个按钮(应该是单词PHP),允许您将语法高亮和自动完成切换到另一种语言,虽然这会暂时关闭PHP语法,但它会允许您进行编码在HTML中更容易。

© www.soinside.com 2019 - 2024. All rights reserved.