【问题标题】:VS Code, how to exclude directory from editor.formatOnSaveVS Code,如何从 editor.formatOnSave 中排除目录
【发布时间】:2018-11-15 22:35:02
【问题描述】:

我在 VSCode 中使用 php 格式化程序,我的问题是在一些也有 html 的视图文件上代码变得混乱,所以我试图从 formatOnSave 中排除文件夹

这是我当前的配置。

"editor.formatOnSave": true,
"[php]": {
    "editor.formatOnSave": false
}

我怎样才能在除视图文件夹之外的所有文件夹中保存 php 格式?

【问题讨论】:

标签: visual-studio-code


【解决方案1】:

如果您使用的是Prettier,那么您可以创建一个.prettierignore 文件并包含要从格式化中排除的目录。您可能需要进入 Prettier 的扩展设置并设置 .prettierignore 的文件路径才能使其生效。

【讨论】:

    【解决方案2】:

    如果您使用的是Beautify,那么可以使用beautify.ignore 选项:

    例子:

    /* ignore all files named 'test.js' not in the root folder,
       all files directly in any 'spec' directory, and
       all files in any 'test' directory at any depth
    */
    "beautify.ignore": ["*/test.js", "**/spec/*", "**/test/**/*"]
    
    /* ignore all files ending in '_test.js' anywhere */
    "beautify.ignore": "**/*_test.js"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-27
      • 2021-11-22
      • 1970-01-01
      • 2010-11-24
      • 1970-01-01
      • 2017-07-18
      • 2020-04-17
      • 1970-01-01
      相关资源
      最近更新 更多