开发者

Configure eclipse so that backspace unindents

Having eclipse configured to use space instead of tabs, is it possible to configure eclipse so that the backspace key unindents like the tab key indents?

A demonstration to clarify what I mean with backspace uninde开发者_如何学Gont (the vertical bar stands for cursor position and the dots for spaces):

if(bar == 0) {
|foo = 0;
}

Pressing tab will indent 4 spaces:

if(bar == 0) {
....|foo = 0;
}

Pressing backspace only goes back 1 space:

if(bar == 0) {
...|foo = 0;
}

What I want is that it goes back 4 spaces:

if(bar == 0) {
|foo = 0;
}


You know that "shift+tab" will outdent a line already, correct?

Hmmm, I just took a look at preferences->general->keys. I only see indent line there, no outdent (or anything useful under "dent").

Personally, I would say that backspace is the key I hit second most often, after space. Rebinding it would drive me bonkers.


According to these very similar questions:

  • In Eclipse, how can spaces behave as tabs?
  • Is there a way to get Eclipse to treat 4 spaces exactly as it treats a tab?

it seems to be not possible :(


The feature will finally be available for next version of Eclipse 4.14 planned for 2019-12 https://www.eclipse.org/eclipse/news/4.14/platform.php#delete-spaces-as-tabs

Backspace/delete can treat spaces as tabs If you use the Insert spaces for tabs option, now you can also change the backspace and delete keys behavior to remove multiple spaces at once, as if they were a tab. The new setting is called Remove multiple spaces on backspace/delete and is found on the General > Editors > Text Editors preference page.


Hard way: set Eclipse to format indention using the tab character. Then backspace will remove the tab char

Easy way: start using the formatting feature of Eclipse to fix the formatting. Ctrl-Shift-F will format the selected lines or the whole file if there is nothing selected, using the formatting rules you configure.

Alternative: select the lines of text you want unindented and use shift-tab, it will unindent the selected lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜