Cannot change the indentation of project files in Intellij? - intellij-idea

I wast to change the indent of all the files in all the projects to 2 spaces. I have no .editoconfig in my project. Even if there is, I have disabled its overriding. I have made the same changes in Project and Default level formatters.
I have size as 2 spaces for Tab size, Indent and Continuation Indent.
But whenever I press enter in a new file, I get a 4 space tab and 4 space indentation.

I would suggest using .editorconfig, just make sure you have the plugin installed. If not, first check Editor -> Code Style for the default options, then check Editor -> Code Style -> Java (for instance) for the specific options for that file type. Any options specified for a file type will override the defaults.

Related

File named "auth_actions.dart" won't be highlighted in Intellij-idea

I created a file named "auth_actions.dart" in a dart project(either angular or not). The file content would have text colour being plain white, without any highlighted.
If I rename it to "auth_action.dart" or "auth_actionss.dart", the highlight will come back.
I did some experiments even from some random projects downloaded from github, all of them had this issue.
Anyone know how to fix it? Does anyone see the same issue using the name "auth_actions.dart"?
I assume you accidentally added the file to
Preferences > Editor > File Types > Recognized File Types > Text
Remove it from Registered Patterns to get hightlighting again.
You could accidentally mark it as plain text (the option is in the right-click menu). In this case, the option to mark it back as a Dart file is also in the context menu.

Sublime tab size only working for some files

Im using Sublime Text 3 for a javascript app. When I tab, I want it converted to 4 sapces. So I have set:
"tab_size": 4,
"translate_tabs_to_spaces": true,
This works fine. But weirdly, on some files (that also have .js extension like the ones it works on), a tab still only translates to 2 spaces. How can i fix this?
In my case, I had to set "detect_indentation": false, and then close and reopen the file. When you leave the file opened, it will "remember" the indentation even across Sublime restarts.
All settings in Sublime Text follow an Order of Precedence. Here's an hypothetical example for JavaScript (in ascending order):
Packages/Default/Preferences.sublime-settings
Packages/Default/Preferences (Windows).sublime-settings
Packages/User/Preferences.sublime-settings
Packages/JavaScript/JavaScript.sublime-settings
Packages/User/JavaScript.sublime-settings
In this case, the bold settings will override all the others. In your case, a JavaScript package might override your user preferences.
What you can do is define tab_size in Preferences > Settings - Syntax Specific. Make sure you're current view is a JavaScript file before opening the setting.

In IntelliJ IDEA, how can I reset the per file indentation decision?

IntelliJ IDEA shows a small notice at the top of a file when the detected indentation inside the file does not match that configured in the settings dialog. It also allows to switch the indentation to the configured setting, which is a useful thing.
But now I have two files for which I would like to revert that decision and not apply my locally defined indentation. However this appears to be impossible...
Even changing the configured indentation setting does not have an effect on those files I once made that decision for. It appears that the decision is set and stored as a per file configuration.
Question: is there any way to remove that per file setting again?
Have you tried Edit -> Convert Indents -> To Spaces / To Tabs ?
This should be file specific.

Intellij indents 4 spaces when I have configured it to do 2 spaces (LESS)

On Intellij IDEA 14, I have tried to set my preferences in Editor > Code Style > LESS to do 2 space indents but no matter what I do, my code ends up getting formatted with 4 space indents. How do I get it to do 2 space indents for LESS?
If your project has an ".editorconfig" file, IntelliJ 14 uses that by default (which overwrites your settings). If you absolutely do not wish to use these settings, you need to disable the editorconfig plugin.
Not as likely, but if you make a scratch buffer and rename it to filename.ext. It does not honor the code style for *.ext, it defaults to tabs. You have to copy the scratch buffer to a real file and then it will apply the code style for *.ext.

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.