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

问题描述 投票:0回答:2

在VS Code中,我已安装并启用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
  }
}

保存时我只想重新输入代码。

visual-studio-code vscode-settings
2个回答
0
投票
对于Windows,单击'文件'->首选项->设置。然后搜索editor.formatOnSave,并输入“ true”而不是“ false”

对于Mac,单击“代码”(在屏幕的左上角,在“文件”,“编辑”和“视图”的左侧)->首选项->设置->在“代码”中输入术语“ editor.formatOnSave”页面顶部的搜索设置框。单击对勾以将其标记为true。

源代码:Beautify on save in VS code?


0
投票
来自Beautify扩展存储库README

在Visual Studio代码中美化javascriptJSONCSSSassHTML。>

您正在尝试格式化PHP代码。

我推荐PHP Intelephense。保存后,它格式化了我的文件:

PHP Intelephense extension

保存前:

PHP code unformatted

保存后:

PHP code formatted

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