Community
Participate
Working Groups
Build Identifier: 20100211-2030 Eclipse editor doesn't remove trailing whitespaces in source code and autoindentation even adds them. Trailing whitespaces are easily added when debugging. Debug code is added and removed, but whitespaces persist. This cause false differences when comparing revisions in source control history. Difference in whitespaces also produces merge conflicts between branches. These changes are always distracting and annoy developers, because they should be manually cared and removed on commits. It may be tempting to propose edit mode that removes trailing whitespaces upon save, but this is not always on, not everybody on a project may use Eclipse, so this is not an option. The proper behavior would be mode that strips trailing whitespaces only from edited lines. See this question for some 13 votes - http://stackoverflow.com/questions/1043433/how-to-auto-remove-trailing-whitespace-in-eclipse Reproducible: Always Steps to Reproduce: Just use autocompletion to type something like. function something() { } function anything() { } and note trailing whitespace between and inside function bodies (PHP Tools at least).
(In reply to comment #0) > (PHP Tools at least). I guess I'll move this to PDT. Platform/UI is for generic bugs in the Eclipse user interface related to views, editors (not text editors mind you, just the editor framework), and perspectives.
I guess it is not only for PDT until it is validated that other editors (Java, JavaScript, Python, C++) can correctly strip whitespaces from edited lines.
(In reply to comment #2) > I guess it is not only for PDT until it is validated that other editors (Java, > JavaScript, Python, C++) can correctly strip whitespaces from edited lines. Platform/IDE is for generic IDE-related bugs like the 'Problems' view. If we're talking about text editors, it goes to Text. The Java editor can delete trailing whitespace with its formatter. I'm not sure if there's a generic solution.
Exactly. Generic solution is needed.
I think you want bug 180349.
No, the #180349 is about removing trailing whitespace globally in the file. This bug is about removing trailing whitespace from edited lines only.
Remy is right, it's a duplicate of bug 180349. The save action would allow to scope the changes to the edited lines (see Java Save Actions for example). *** This bug has been marked as a duplicate of bug 180349 ***
Issue #180349 is a generalization that doesn't cover this specific case. Changing title, reopening and adding #180349 as dependency.
This is what will happen with bug 180349 i.e. it will allow to only remove the trailing whitespace of touched lines. *** This bug has been marked as a duplicate of bug 180349 ***
(In reply to comment #9) > This is what will happen with bug 180349 i.e. it will allow to only remove the > trailing whitespace of touched lines. Bug 180349 doesn't list this case. It seems that the original reporter meant that trailing spaces should be stripped globally when file is saved. If you clarify that in bug 180349 case, I will agree to close this ticket as duplicate and not as dependency.
When solving a bug we also look at the duplicates, so there's no need for additional bloat in the other bug. If you don't trust that then you can also add a comment yourself there but please stop reopening this bug. *** This bug has been marked as a duplicate of bug 180349 ***
On the second thought I do not want whitespaces to be deleted upon save, but rather immediately if I leave the edited line. Should I reopen this bug?
>On the second thought I do not want whitespaces to be deleted upon save, but >rather immediately if I leave the edited line. Should I reopen this bug? This would not be enough because whitespace would not be deleted for the current line when you save and close the editor, hence you need to have it on save.
(In reply to comment #13) > >On the second thought I do not want whitespaces to be deleted upon save, but > >rather immediately if I leave the edited line. Should I reopen this bug? > This would not be enough because whitespace would not be deleted for the > current line when you save and close the editor, hence you need to have it on > save. Then whitespace should deleted from the current line, when editor freezes, loses focus or releases control. Or better - whitespaces should not be added until a symbol is entered in the middle of line.