[ANN] HungryBackSpace 0.7 plugin released


New feature: HungryBackSpace will now pause at the indent column. This behavior is controllable by toggling Options->Backspace Stops at Indent in menubar (default on). Note that with the Stop At Indent option, only the last indent will be stopped at. For example, if there are 10 blank lines above the caret, and you press Backspace, the first 9 blank lines will be gobbled up, and then the caret will be positioned at the indent column on the remaining blank line. Pressing backspace again will move caret to end of previous line.

Given Following Code (A)

With Stop At Indent on, BackSpace will produce (B)

Pressing BackSpace again, will produce (C)

With Stop At Indent off, pressing BackSpace with Code (A) above will produce (D)

Which is the same as result as (C) which was achieved by pressing BackSpace twice with Stop At Indent on.

I have been using it for a few hours with Stop At Indent on, and it has been working well. With this latest enhancement, I feel even more strongly that this should be the default BackSpace behavior in Intellij.

Please post if there are any problems. One part of the code is kind of kludgy (determining the indent column), so it is possible there may be problems in certain cases.


Is the following behavior intented or am I doing something wrong?

Start with:

Using Hungry Backspace(with stop at indent on):

In reality, what I wanted was:

Now, if there were no statment on the line, then Hungry Backspace does:

Likewise, take the following example:

Using Hungry Backspace(with stop at indent on):

Or, take the following example:

Using Hungry Backspace(with stop at indent on):

What I really wanted was:

Yeah, I know there are other ways to reformat the lines, but when it is just a few lines, backspace, arrow(up or down), and delete usually work best for me.

I would like to have functionalilty of the Hungry Backspace, but not as the primary function of the backspace key.

I keep removing the plugin, because it causes me to much confusion. I want it, but not always on.


I'm not exactly sure what you are describing, but...

If the caret is already at the current indent level, then pressing BackSpace will eat up whitespace up to the next line.

That looks like what is happening in your example:

>Using Hungry Backspace(with stop at indent on):

What I really wanted was:

You weren't very clear, but I guess your example has
statement1, statement2, statement3 at the wrong
indent levels? And you want BackSpace to correct
the indent level?

Or you just want BackSpace to act like there are
indent stops every X spaces, and pressing BackSpace
would backup your line to the next indent level,
regardless of whether it is the correct ident level
or not?

I think in the normal case when the lines are already indented properly, it works very well.

I think you are talking about special cases where the
lines are not at the correct indent level.

I am working on an AutoNewLine package which provides
CCMode AutoNewline funcxtionality. It works very nice
with HungryBackSpace because each time you press
or ; the line is reindented if necessary and
the newline is added automatically. I also override
TAB key to reindent the current line; You can approximate
that right now by binding TAB to Code->Auto Indent Lines.


In my examples, the code was not at the right indent level; that is, the statements were 1 tab to far to the right. Though, that is why I included the 'what I wanted' examples.


Okay, I found out that this case is a problem.
Statement1 and statement2 are at the correct indent level,
while statement3 is not.

When you press BackSpace, you get:

which is incorrect. It should be:

Note that if the caret was on a blank line, it works:


I will be fixing this case. However, I don't see how to fix your more complicated case were several lines are indented wrong, and you want BackSpace to figure out the correct indent level.. I think in that case, you should just reindent the region/file again. I use that handy
ReformatPlugin so I can just hit CTRLALTR to reindent
the file.