Is it possible to format html in a multi-line string? E.g. in an AngularJS 2 template.


For example the angular tutorial has the following code in a multi-line comment (declared with ` )

<h2>{{}} details!</h2>
<div><label>id: </label>{{}}</div>
<label>name: </label>
<input [(ngModel)]="" placeholder="name">

None of the code styles I've looked at seem to have a way to  format the html within the multi-line comment.  Is there a way to do this (other than manually) - or at least specifically with Angular components?




You can place the cared inside of the HTML code, press Alt+Enter and select "Edit HTML fragment", then apply code format in opened HTML fragment - it will be propagated to the original file.


Thanks for your response. That sort of works, and reformatting the html fragment looks nice, but it still leaves in unformatted in the actual file, eg: 

I'm trying to get a formatting similar to this:



Unfortunately, there's no straight way to do this at the moment. You can try to manually set the line breaks and enable "Keep line breaks" in File | Settings (PhpStorm | Preferences for Mac) | Editor | Code Style | HTML > Other.

We already have a related request submitted to our tracker here: <>. Please vote for it in order to move it up in the queue and receive notifications regarding the progress of the feature. See more information on working with tracker at <>.


Thanks! I've gone ahead and done both your suggestions.


Please sign in to leave a comment.