Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto indent jsx in VSCode

VSCode seems doesn't auto indent HTML elements in jsx?

enter image description here

Is there any way to fix it.


Update:

In Atom:

When I input <div>, atom will show: enter image description here

After I press the return key, the result is(pay attention to the location of the cursor): enter image description here

While in VSCode:

enter image description here

enter image description here

like image 647
zhuscat Avatar asked Nov 09 '16 00:11

zhuscat


People also ask

How do I beautify a JSX file?

You can use hot key Ctrl+M (Command+M) to beautify your JSX file.


1 Answers

Try changing the language mode to JavaScript React.

  1. Open the commands palette.
  2. Type change language mode
  3. Press Enter
  4. Type javascript react
  5. Press Enter

Once that's done, you'll see the JavaScript React mode in the bottom left corner.

Confirmation of JavaScript React Mode

Once you're in that mode, try again to format the document.

like image 50
Shaun Luttin Avatar answered Sep 19 '22 12:09

Shaun Luttin