IntelliJ IDEA JSX code style - intellij-idea

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?

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.

Related

WebStorm Smarty highlighting

Is there an way to make WebStorm highlight Smarty templates? Either through plugin or some other means?
Also note, I need this for WebStorm, not PhpStorm or some other version; I don't need autocomplete or anything else -- just highlights.
Files have .tpl extension and so far I'm treating them as HTML files and I am looking for options to increase code readability with coloring.
I have tried following based on the comments:
However, resulting .tpl file still looks like

How to configure Intellij for Tabs to Spaces for Only Certain File types

Most file types I want to have tabs converted to spaces. However not in Markdown. I went to the Markdown specific File type and see only limited ability to customize it. Is there some way to define filetype-specific editing behavior in Intellij?
IntelliJ normally allows you to set indentation settings per language in Code style section of the settings. As far as I know Markdown is not included out of the box and support for it must be installed via plugin. But the plugin doesn't seem to enable Code style configuration for Markdown.
So the only solution I can think of is to set tabs as default indentation in General section of Code style settings and then override it to spaces for individual languages (but that may not be necessary because the code style settings for individual languages will have spaces as default).
One downside of this is that if you work with some filetype other than Markdown which is not natively supported in IntelliJ, it will use tabs even though you might want to use spaces for that filetype.
Alternatively you could create feature request for this functionality either in IntelliJ or the Markdown plugin itself.
EditorConfig can do what you want. Just add a file .editorconfig to the root directory of your IntellJ project. The following .editorconfig example will set all files by default to use the 4-character-wide tab character as the indentation, and then a list of other files (and everything in the directory dir2) to use 2 spaces as the indentation.
#top-most EditorConfig file
root = true
[*]
indent_style = tab
indent_size = 4
[{File1.ext,dir1/file2.ext,dir2/*}]
indent_style = space
indent_size = 2
The file matching format is pretty versatile.
IntelliJ IDEA (and some other JetBrain products) should have this installed by default with no need for a plugin. Others may need a plugin.
I would personally recommend adding these other configs for general compatibility and cleanliness
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
I used it as a workaround, Editor->Code Style->Other File Types

PhpStorm shows Haml file like plain text (transcompilation works, but not the syntax highlighting)

The syntax highlighting for my haml files in PhpStorm does not work, and the icon is just the icon for plain text. (It should be a red icon with an h, similar to the icon for the scss file.)
The transcompilation works only if File type in the watcher is set to Text files. If I choose HAML files, it tells me that there are "No such files in scope".
Any ideas, why PhpStorm recognizes the scss file, but not the haml file?
First of all -- make sure that HAML support plugin is installed and enabled (whould be by default).
If plugin is good:
Settings | File Types
Text files entry
Find and remove offending pattern (quite possible will be background-clip.haml or similar)

IntelliJ auto detect indentation for each file

I recently switched from Sublime Text to IntelliJ and I trying to figure out, if there's a way for IntelliJ to auto detect what indentation the current file is using and use that instead of the default
I have to deal with a lot of 3rd party code, which can have different indentation settings, which I'm not allowed to change for obvious reasons.
Sublime Text was able to detect and abide to the indentation for the current file, which is quite intuitive and unobtrusive. IntelliJ on the other hand just sticks to it's own settings, resulting in mixed tabs and spaces, wrong indentation levels and wrong merge conflicts.
Is there a way to make IntelliJ behave, other than having to manually change the indentation settings every time I get a file with different indentation.
Thanks
In recent versions of Intellij there is a Detect and use existing file indents for editing setting for this:
Each project you open in IntelliJ has it's own settings. You will need to set the indent style the first time you open up the project, but it will be saved after that (and can be different for every project you work on). From the IntelliJ help site:
Project settings are stored with each specific project as a set of xml files
under the .idea folder. If you specify the
default project settings,
these settings will be automatically used for each newly created project.
You can edit the indent settings for the project in the Code Style dialog.

IntelliJ idea - any way to change visual line wrapping icon?

I really like Intellij's line wrapping feature with icons marking line wraps. Hovewer the default wrapping icon's readability is far from ideal.. is there any way I could fix this little problem?
Current solution is to use standard unicode symbols from supplementary arrows set: 2925 and 2926.
You can modify that by specifying other unicode (hex) codes via idea.editor.wrap.soft.before.code and idea.editor.wrap.soft.after.code properties in idea.properties file. Note that it's necessary to define both symbols, e.g. add to the idea.properties something like below:
idea.editor.wrap.soft.before.code=2906
idea.editor.wrap.soft.after.code=2907
Note that not all the fonts contain all the Unicode characters, so you have to choose the proper font in Settings | Editor | Colors & Fonts and specify the symbol code that exists in the font that you are using.
To clarify what CrazyCoder said:
On a Mac, you'll need to go into finder and "show package contents" on the Intellij IDEA.app, then you can add lines to the idea.properties file in the "bin" folder. Here's the arrow codes I went with:
idea.editor.wrap.soft.before.code=219e
idea.editor.wrap.soft.after.code=21a0
Don't forget, you can also change their color in the program's preferences under "editor > colors and fonts > general > soft wrap sign".