How to put cursor at the head of line when press backspace?

Hi, 

I am on a custom language FormattingModelBuilder , using the code below to indent after pressed Enter.

public ChildAttributes getChildAttributes(int newChildIndex) {
return new ChildAttributes(Indent.getNormalIndent(), null);
}

It would be like this after pressed Enter:

statement_1
  |(cursor)

Then, I press Backspace and I hope the cursor can be put at the head of line:

statement_1
|(cursor)

But actually, It is this:

statement_1|(cursor)

So, what I should do to put the cursor at the head of current line rather than the end of last line?

 

Thanks in advance.

0
2 comments

This is controlled by a global editor setting (Settings->Editor->General->Smart Keys->Backspace->Unindent). By default it's set to 'To proper indent position', and as the caret is already positioned at correct indent position for the current line, it's moved to the end of previous line. If you want it to work differently, you can use e.g. 'To nearest indent position' instead.

If 'To proper indent position' doesn't make sense at all for you language (as e.g. for Python where indenting is used to define code blocks), you can register BackspaceModeOverride instance for your language (see e.g. how SmartBackspaceDisabler is registered for Python as an example).

0

Dmitry, thank you very much. It exactly what I want.

0

Please sign in to leave a comment.