Cursor placement on empty lines inside brackets (classes, methods etc.)

Answered

Hello, IDEA community!

I'm currently working on a small project using the IntelliJ IDE, and I like it!

But there's one thing that's bugging me, and that's when I click on an empty line within a class or method (that is, within the brackets '{' *HERE* '}').

The cursor automatically jumps all the way to the left (at the beginning of the selected line), when I expect it to automatically be placed approximately one tab from the bracket.

Example:

How it behaves when I click

How I want it to behave

 

I know there's an option to make it behave in such a way, that the cursor is placed exactly where you click. This is unfortunately not what I want.

I can also format my code every time I write some, but it also feels annoying to me.

 

So, is there a way to make it behave like this?

 

Kind regards, Mark.

1
5 comments

You need to set indents  at Preferences | Editor | Code Style | Java | Tabs and indents.

0

I found an option called "keep indents on empty lines", but it only works for newly created lines, not the ones already there.

I couldn't find any option for the one I'm looking for. I'm used to Visual Studio, and if you've ever used that IDE, I'm sure you know what I'm looking for.

Thanks.

0

Could you please provide a screenshot of Preferences | Editor | Code Style | Java | Tabs and indents settings page?

0

Sure Petr!

Here:

0

Try setting "keep indents on empty lines", and then invoking "Code | Reformat code".

0

Please sign in to leave a comment.