Visual Studio Code 中 PHP/HTML 的格式代码命令 [英] Format code command for PHP/HTML in Visual Studio Code

查看:29
本文介绍了Visual Studio Code 中 PHP/HTML 的格式代码命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让 Visual Studio Code 在 Windows Visual Studio Code 版本 0.7.1 上格式化混合的 HTML 和 PHP 代码?

Is it possible to get Visual Studio Code to format mixed HTML and PHP code on Windows Visual Studio Code version 0.7.1?

推荐答案

更新2021-07-21

距离我第一次写这个答案已经有五年多了.我最初链接的扩展被放弃了,Visual Studio Code 的内在 PHP 支持没有改进,这令人失望.我所知道的唯一一个不错的扩展是 PHP Intelephense,它使用免费增值模式:基本功能是免费的,在撰写本文时,终身许可为 12 美元.

Update 2021-07-21

It's been more than half a decade since I first wrote this answer. The extensions to which I originally linked are abandoned, and Visual Studio Code's intrinsic PHP support hasn't improved, which is disappointing. The only decent extension still standing of which I'm aware is PHP Intelephense, which uses a freemium model: basic features are free, and a lifetime license is $12 USD as of writing.

免费版本的 Intelephense 支持使用常用快捷键(在 Windows 和 Linux 上为 Alt + Shift + F⌥⇧F 在 macOS 上).Visual Studio Code 仍然缺乏对 PHP 代码格式化的内置支持,如果您在未安装适当扩展的情况下尝试格式化 PHP,则会将您引导至扩展市场.

The free version of Intelephense supports code formatting with the usual shortcuts (Alt + Shift + F on Windows and Linux, ⌥⇧F on macOS). Visual Studio Code continues to lack built-in support for PHP code formatting and will direct you to the extension marketplace if you attempt to format PHP without an appropriate extension installed.

Visual Studio Code 具有非常棒的 PHP 支持.extensions 涵盖了它所缺少的内容.快速搜索发现至少三个(1, 23) 声称支持 PHP 格式.

Visual Studio Code has pretty awesome PHP support. What it lacks is covered by extensions. A quick search reveals at least three (1, 2, and 3) that claim to support PHP formatting.

他们似乎在 Windows/Linux 上使用标准快捷键 Alt + Shift + F,在 Mac 上使用不同的快捷键.如果您使用的是 Mac,请尝试 ⌥⇧F.

They mostly seem to use the standard shortcut of Alt + Shift + F on Windows/Linux, with varying shortcuts on Mac. If you're on Mac, give ⌥⇧F a try.

这篇关于Visual Studio Code 中 PHP/HTML 的格式代码命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆