I have a JSX file with two-space indents, but IntelliJ keeps adding four-space indents. Changing Settings>Editor>Code Style
for Javascript, HTML, and "other file types" does not seem to affect this.
How can I change the code style for JSX files?
Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).
JSX stands for JavaScript XML. It is simply a syntax extension of JavaScript. It allows us to directly write HTML in React (within JavaScript code). It is easy to create a template using JSX in React, but it is not a simple template language instead it comes with the full power of JavaScript.
. tsx is similar to jsx except it's TypeScript with the JSX language extension.
Turns out the reason the IDE wasn't responding to my settings changes is it was using EditorConfig mode (Settings>Editor>Code Style>EditorConfig
). Editing the .editorconfig
file to have the line indent_size = 2
fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With