How do regular expression work, when disabling code formatting

Answered

Hi, I'm using Intellij 15.02.

In settings > editor > code style > general > formatter control, there is a regular expression checkbox. IJ help simply say this:

Select this check box to use regular expressions instead of specifying the formatting markers explicitly.

How do I use this feature?

Regards,
Gilbert


4 comments
Comment actions Permalink

IDE will match formatter on/off markers using the regular expression you specify instead of the exact string.

0
Comment actions Permalink

Hi, I am sorry but I don't get it, it's not exactly intuitively obvious - could you provide a simple example of what you mean, how to use it? 

Does this mean that you can exclude individual lines based on a regexp provided?  Again, a simple example would be appreciated.

 

Thanks

Jiri 

0
Comment actions Permalink

Hi, it seems to me that regex option is not working with doc blocks

If I'm wrapping my dock blocks with

// @formatter:on/off

all is working fine and  the problem below is not occurring

but if Im defining them as regex, it seems to work in code, but not in dock blocks.

/**                 
* @apiErrorExample {json} Invalid-Input-Response:
{
"error": {
"message": "Input not found",
"status_code": 400
}
}
*/

turns to

/**
* @apiErrorExample {json} Invalid-Input-Response:
* {
* "error": {
* "message": "Input array not found",
* "status_code": 400
* }
* }
*/

maybe my simplistic regex is not correct, but it works in a regular search dialog

@api[a-z,A-Z]+Example  <-as formatter off
}\s+\* <- as formatter on

I know that the regex works because this code is not reformatted, which is correct

//* @apiErrorExample
$array = [1,
2,
3];
//} *
0
Comment actions Permalink

@Jekabs Could you please create a bug report on our tracker: https://youtrack.jetbrains.com/newIssue?

0

Please sign in to leave a comment.