How to navigate caret at the same level as the block of code

Answered

Hi,

I have a rather simple question, let's say we have the following code:

public void add (int stuff) {

    while (flag) {

 

    }

}

 

Then move the caret with a mouse click inside the while loop (in between the curly braces). 
What happens is, intellij moves the caret to the very left side, without any indentations.
How can I select inside the inner block of code, and keep on writing code at the same level as that specific block?

Thank you

3 comments
Comment actions Permalink

It looks like in your code there is an empty line inside while block. You can't place a caret after end of line by default, therefore it's placed in the beginning of the line when you click.

You can place it after { and press Enter for auto indent or you can press End to auto indent inside block when it's in the beginning of the line.

0
Comment actions Permalink

Thanks, pressing End solves this. 

0
Comment actions Permalink

The option is: Settings => Editor => General => Virtual Space section => Allow placement of caret after end of line

 

(Actually IIRC that setting was enabled by default in previous IDEA versions and after much discussion in the forum the default was changed to OFF.)

0

Please sign in to leave a comment.