Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to config intellij-idea not format some part of the code?

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> 

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> 
like image 444
Freewind Avatar asked Dec 24 '12 10:12

Freewind


People also ask

How do I stop formatting in IntelliJ?

You must go to Preferences -> Code Style -> General -> Formatter Control and check Enable formatter markers in comments for this to work.

How do I tidy up code in IntelliJ?

Press Ctrl+E, C or choose Code | Reformat and Cleanup… from the main menu . In the Code Cleanup dialog that opens, you can check and optionally change the scope for cleaning code and choose a cleanup profile to apply.


1 Answers

In my version EAP 13.1, you must enable the following option in settings,

Preferences -> Code Style -> General -> Formatter Control -> Enable formatter markers in comments

before you can use these comments,

// @formatter:off  // @formatter:on  

or these (depending on language):

<!--@formatter:off-->  <!--@formatter:on--> 

Screenshot:

Screenshot highlighting the checkbox for Enable formatter markers in comments under Preferences

like image 116
fawkes Avatar answered Sep 18 '22 03:09

fawkes