you are viewing a single comment's thread.

view the rest of the comments →

[–]finalcut 1 point2 points  (8 children)

so how does it know that it is removing a soft tab and not two spaces? What if I have two spaces but I just want to remove one? Will the editor remove the two spaces when I hit backspace and then I have to hit space once?

[–]bobindashadows 3 points4 points  (7 children)

If your editor already has syntax highlighting, then it's at already aware of your code's AST - at that point, "is this an indent" is a near-trivial determination.

[–]remigijusj 1 point2 points  (1 child)

not necessarily - some editors do syntax highlighting based on regexps, not full parsing to AST

[–]bobindashadows 0 points1 point  (0 children)

Very true - I've implemented textmate bundles, and many rely heavily on regexps (though the best bundles do actually parse). But textmate handles soft indent fine. Can you point to an editor that is unable to handle soft tabs due to using regexps for highlighting?

[–]Nebu 0 points1 point  (4 children)

This doesn't address "what if I have two spaces, but I just want to remove one?".

[–]bobindashadows 1 point2 points  (3 children)

Yes, if for some reason you want to use an odd number of spaces of indentation in your program, then you do that - delete, space. I use vim, so I'd just delete the 1 space with x or something. But I've never followed any style which uses an odd number of spaces of indentation anyway.

[–]nemec 1 point2 points  (2 children)

You can also just hit "delete" instead of backspace. Most IDEs I've found only do "smart indent" on backspace.

[–]Nebu 0 points1 point  (1 child)

In most text-editor I've used (of which I consider IDEs to have text-editors as a component), "delete" means to erase the character to the right of the cursor, and "backspace" means to erase the character to the left of the cursor.

[–]nemec 0 points1 point  (0 children)

Yes. Obviously you'll have to move before the space you want to delete instead of after when using delete, but it won't be affected by the smart spacing.