在VS代码中,我安装并启用了Beautify。

https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify
我在我的一个php文件上测试了,

当我按下保存,我不能恢复或美化发生。
我错过了什么?
代码>用户> settings.json
{
"workbench.startupEditor": "newUntitledFile",
"window.zoomLevel": 1,
"editor.fontSize": 14,
"terminal.integrated.fontSize": 11,
"extensions.ignoreRecommendations": true,
// syncedSideBar
"explorer.autoReveal": true,
// Is git enabled
"git.enabled": false,
// Path to the git executable
"git.path": null,
// Whether auto fetching is enabled.
"git.autofetch": false,
"workbench.statusBar.visible": false,
"workbench.activityBar.visible": true,
"eslint.autoFixOnSave": true,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
"workbench.colorTheme": "Monokai",
"javascript.updateImportsOnFileMove.enabled": "always",
"openInGitHub.providerType": "github",
"gitlens.advanced.messages": {
"suppressGitDisabledWarning": true
},
"liveServer.settings.donotShowInfoMsg": true,
"window.closeWhenEmpty": false,
"editor.emptySelectionClipboard": false,
"editor.dragAndDrop": false,
"editor.fontFamily": "Source Code Pro",
"editor.selectionHighlight": false,
"window.openFilesInNewWindow": "off",
"workbench.editor.enablePreview": true,
"editor.scrollBeyondLastLine": false,
"editor.mouseWheelScrollSensitivity": 5,
"window.title": "${activeEditorFull}${separator}${rootName}",
"editor.tabSize": 4,
"files.trimTrailingWhitespace": true,
"editor.useTabStops": true,
"editor.wordWrap": "on",
"editor.formatOnPaste": false,
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "top",
"vsicons.dontShowNewVersionMessage": true,
"files.autoSave": "afterDelay",
"editor.formatOnType": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}我只想在保存代码时重新记忆代码。
发布于 2020-03-21 01:12:54
来自美化扩展repo README
美化Visual Studio代码中的
javascript、JSON、CSS、Sass和HTML。
您正在尝试设置PHP代码的格式。
我推荐PHP Intelephense。我的文件在保存时格式化得很好。

保存前:

保存后:

要点:仅在文件不包含结束?> php标记时格式化文件。您必须删除您的结束标记。来自PHP Tags documentation
如果文件只包含PHP代码,最好省略文件末尾的PHP结束标记。这可以防止意外的空格或新行被添加到PHP结束标记之后,这可能会导致不想要的效果,因为PHP将在程序员无意在脚本中发送任何输出时启动输出缓冲。
发布于 2020-03-22 23:10:46
发布于 2020-03-18 22:00:15
对于视窗系统,点击‘文件’->偏好设置->设置。然后搜索editor.formatOnSave,输入"true“代替"false”
对于Mac电脑,点击“代码”(屏幕的左上角,“文件”、“编辑”和“查看”的左边) -> Preferences ->设置->在页面顶部的搜索设置框中输入“editor.formatOnSave”。单击复选标记将其标记为true。
https://stackoverflow.com/questions/60656593
复制相似问题