Intellij idea 如何配置intellij idea而不是格式化部分代码?
在html文件中,有一些代码用于自定义模板语言:Intellij idea 如何配置intellij idea而不是格式化部分代码?,intellij-idea,code-formatting,Intellij Idea,Code Formatting,在html文件中,有一些代码用于自定义模板语言: <script type="text/javascript"> function ($scope, JsRoutes) { $scope.rows = [ ${"#{list rows, as: 'row', separator: ','}"} { #{list fieldConfigs, as: 'f', separator: ','}
<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>
<!--@formatter:off-->
<!--@formatter:on-->
函数($scope,JsRoutes){
$scope.rows=[
${“#{将行列为:'行',分隔符:','}”
{
#{列表字段配置,如:'f',分隔符:','}
${f.name}:${'$'}{row.${f.name}.toJson()}{{/list}
}
${{/list}
]
}
是否可以将intellij idea配置为不格式化(而是格式化文档的其他部分)?由于idea会使格式化后的阅读变得困难:
<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>
函数($scope,JsRoutes){
$scope.rows=[
${“#{将行列为:'行',分隔符:','}”
{
#{列表字段配置,如:'f',分隔符:','}
${f.name}:
${'$'}{
行。${f.name}.toJson()
}#{/list}
}
${{/list}
]
}
此功能已经实现,您现在可以使用特殊注释禁用代码区域的格式设置
在设置中启用此功能后,在区域的开头添加/@formatter:off
,在区域的结尾添加/@formatter:on
这些是默认标记,并且是可配置的
你可以找到:
2012年的原始答复: 目前还不可能,请投票支持此功能请求:
- 使用注释禁用每个区域的代码格式设置
// @formatter:off
...
// @formatter:on
要在“环绕”中启用它,您可以在“环绕”部分定义活动模板,包括:
您可以在
设置
->代码样式
->常规
中找到这些设置,并设置您自己的触发字。在我的版本EAP 13.1中,您必须在设置中启用以下选项
首选项
->代码样式
->常规
->格式化程序控件
->在注释中启用格式化程序标记
在使用这些注释之前
// @formatter:off
// @formatter:on
或这些(取决于语言):
截图:
值得注意的是,格式化程序控件在javadoc注释中似乎不起作用。它需要在常规的C或C++风格的注释中。所以
/@formatter:off
有效/*@formatter:off*/
也有效,但/**@formatter:off*/
不起作用。这为我带来了窍门,谢谢!我认为这应该是可以接受的答案,因为它同时被添加为IntelliJ IDE的一项功能。我不想在我的代码上使用注释,只是为了IntelliJ不破坏我的缩进,我一直在努力调整,例如定义属性。此设置应可用于整个项目,无需注释。但是当我说格式或缩进时,我希望能够重新格式化。现在我只剩下通过遍历Java代码样式和复选框来完全关闭该功能
<!--@formatter:off-->
<!--@formatter:on-->