Search code examples
androidandroid-studiointellij-ideacode-editor

IntelliJ "keep indents on empty lines" not working


In Android Studio, i would like to setup the code editor, so i could move cursor with keyboard arrows, or click with a mouse somewhere on a blank line, and the cursor will be placed right bellow the start of a previous line of code.

enter image description here

as i understand, the option keep indents on empty lines should activate this kind of behavior, but unfortunately after setting it up, i still cannot achieve what i wont. if cursor goes to empty line, it is always at the beginning of the line. tried to restart Android Studio, wasn't helpful.

Googled a lot didn't find any info.

If someone knows how to get that behavior, help will be very appreciated.


Solution

  • There's an issue in Intellij-Idea very similar to this one that might apply here.

    https://youtrack.jetbrains.com/issue/IDEA-144196

    The workaround I found was to set the 'Strip trailing spaces on save' option in Settings > Editor > General to 'None'. This works in addition to enabling options in your code style settings that keep the indent on empty lines. From what I can surmise, it seems like the logic that applies the rule to indent conflicts or has some sort of order of operations rule issue with the option to strip trailing spaces.

    It's not a perfect workaround... by doing this, you get to keep your tabs on empty lines, but it comes at the cost of also retaining any empty spaces at the end of lines.

    I'm not sure if they've fixed this for the Idea 15 release, but if the status of the issue is any indicator, I'm betting not. There may be better workarounds than this one. It's just the one that I tried that yielded acceptable results.