如何配置intellij-idea不格式化代码的某些部分? [英] How to config intellij-idea not format some part of the code?

查看:913
本文介绍了如何配置intellij-idea不格式化代码的某些部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在html文件中,有一些代码使用自定义模板语言:

In a html file, there is some code used custom template-language:

<script type="text/javascript">
    function ($scope, JsRoutes) {
        $scope.rows = [
            ${"#{list rows, as: 'row', separator: ','}"}
            {
            #{list fieldConfigs, as: 'f', separator: ','}
            ${f.name} : ${'$'}{row.${f.name}.toJson()}#{/list}
            }
            ${'#{/list}'}
        ]
    }
</script>

是否可以配置intellij-idea不格式化(但格式化文档的其他部分) )?因为在格式化之后,想法会使其难以阅读:

Is it possible to configure intellij-idea not to format it(but format the other part of the document)? Since idea will make it hard to read after formatting:

<script type="text/javascript">
    function ($scope, JsRoutes) {
        $scope.rows = [
            ${"#{list rows, as: 'row', separator: ','}"}
            {
    #{list fieldConfigs, as: 'f', separator: ','}
    ${f.name} :
        ${'$'}{
            row.${f.name}.toJson()
        }#{/list}
    }
    ${'#{/list}'}
    ]
    }
</script>


推荐答案

此功能已实施,您现在可以禁用格式化对于使用特殊注释的代码区域。

This feature has been implemented and you can now disable formatting for the regions of code using the special comments.

你可以查找文档中的更多详细信息和示例

  • Skipping a region when reformatting source code
  • Example of using formatting markers

2012年的原始答案:

Original answer from 2012:

现在还不行,请v此功能请求的注明:

  • IDEA-56995 Disable code formatting per region using comments

这篇关于如何配置intellij-idea不格式化代码的某些部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆