首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在VS Code中保存的代码中重新插入代码?

如何在VS Code中保存的代码中重新插入代码?
EN

Stack Overflow用户
提问于 2020-03-12 22:50:55
回答 3查看 709关注 0票数 1

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

https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify

我在我的一个php文件上测试了,

当我按下保存,我不能恢复或美化发生。

我错过了什么?

代码>用户> settings.json

代码语言:javascript
复制
{
  "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
  }
}

我只想在保存代码时重新记忆代码。

EN

回答 3

Stack Overflow用户

发布于 2020-03-21 01:12:54

来自美化扩展repo README

美化Visual Studio代码中的javascriptJSONCSSSassHTML

您正在尝试设置PHP代码的格式。

我推荐PHP Intelephense。我的文件在保存时格式化得很好。

保存前:

保存后:

要点:仅在文件不包含结束?> php标记时格式化文件。您必须删除您的结束标记。来自PHP Tags documentation

如果文件只包含PHP代码,最好省略文件末尾的PHP结束标记。这可以防止意外的空格或新行被添加到PHP结束标记之后,这可能会导致不想要的效果,因为PHP将在程序员无意在脚本中发送任何输出时启动输出缓冲。

票数 4
EN

Stack Overflow用户

发布于 2020-03-22 23:10:46

Beautify official github repository上已经列出了相同的问题

根据他们的回复

PHP不支持

如果你想美化PHP文件,你必须使用不同的插件,例如:

phpfmt - PHP formatter

票数 1
EN

Stack Overflow用户

发布于 2020-03-18 22:00:15

对于视窗系统,点击‘文件’->偏好设置->设置。然后搜索editor.formatOnSave,输入"true“代替"false”

对于Mac电脑,点击“代码”(屏幕的左上角,“文件”、“编辑”和“查看”的左边) -> Preferences ->设置->在页面顶部的搜索设置框中输入“editor.formatOnSave”。单击复选标记将其标记为true。

源:Beautify on save in VS code?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60656593

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档