【问题标题】:How to stop formatting php code in .html file using vscode如何使用 vscode 停止格式化 .html 文件中的 php 代码
【发布时间】:2019-05-16 06:27:04
【问题描述】:

我正在使用 vscode 对 PHP 项目中的视图文件进行编码。一种传统的方法是在 HTML 视图文件、javascript 代码块中回显变量,使用<?php echo $var; ?>。

例如:

<script type="text/javascript">
var i = <?php echo $i; ?>;
</script>

这是我想要的,但是 vscode 不断将代码格式化为

<script type="text/javascript">
var i = < ? php echo $i; ? >;
</script>

我的 vscode 格式设置是:

  "beautify.language": {
    "html": ["htm", "html", "php", "erb"],
    "css": ["css"],
    "js": []
  },
  "beautify.config": {
    "indent_char": " ",
    "max_preserve_newlines": 1,
    "html": {
      "indent_size": 4,
      "unformatted": ["span", "label", "a"],
      "wrap_line_length": 0
    },
    "js": {
      "indent_size": 4,
      "wrap_line_length": 0
    },
    "css": {
      "indent_size": 2
    }
  },

【问题讨论】:

    标签: php html visual-studio-code format


    【解决方案1】:

    尝试使用以下设置:

    "beautify.language": {
        "html": ["htm", "html", "erb"],
        "css": ["css"],
        "js": []
      },
      "beautify.config": {
        "indent_char": " ",
        "max_preserve_newlines": 1,
        "html": {
          "indent_size": 4,
          "unformatted": ["span", "label", "a"],
          "wrap_line_length": 0
        },
        "js": {
          "indent_size": 4,
          "wrap_line_length": 0
        },
        "css": {
          "indent_size": 2
        }
      },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-31
      • 2018-05-08
      • 2023-02-02
      • 2018-12-22
      • 2014-03-28
      • 2021-03-02
      • 2018-10-20
      相关资源
      最近更新 更多