Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reformat HTML code in JavaScript file in PhpStorm

I'm using PhpStorm 2016.2 and developing a web application with VueJS.

In PhpStorm I would like reformat HTML code in my JavaScript file. But when I click Code | Reformat only JavaScript is reformatted.

How to reformat both JavaScript and HTML?

HTML code in a JavaScript file is not reformatted by PhpStorm

like image 335
Rifton007 Avatar asked Jun 11 '26 05:06

Rifton007


2 Answers

I found another solution to my problem with PhpStorm 2016. Use the Fragment Editor.

  1. Place the cursor on your HTML code fragment.
  2. Press the ALT + ENTER key and click on "Edit HTML Fragment"
  3. Reformat your html code in the fragment editor.
  4. Your Javascript file is updated directly.
like image 62
Rifton007 Avatar answered Jun 13 '26 18:06

Rifton007


2016.2 doesn't support formatting HTML injected in Typescript/ECMAScript 6. This feature (WEB-18307) is available since 2017.1, see https://www.jetbrains.com/help/webstorm/2017.1/using-language-injections.html#d240474e440

like image 37
lena Avatar answered Jun 13 '26 18:06

lena