editorconfig / editorconfig

EditorConfig universal issue tracker and wiki
http://editorconfig.org
3.2k stars 103 forks source link

Clarify behavior of `trim_trailing_whitespace` on existing lines #208

Open steverice opened 9 years ago

steverice commented 9 years ago

I've combed through the documentation and can't find anything that explicitly answers this question: If I set trim_trailing_whitespace to true, does that mean trailing whitespace is trimmed from all lines or just modified lines?

This comment suggests it's modified only. In any case that's an important thing to consider when deciding whether or not to enable that property.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9500445-clarify-behavior-of-trim_trailing_whitespace-on-existing-lines?utm_campaign=plugin&utm_content=tracker%2F76099&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F76099&utm_medium=issues&utm_source=github).
jednano commented 9 years ago

That would be great to clarify the language on that feature. I can tell you that the Visual Studio plugin trims all trailing whitespace of all lines in the documents, but other editors might handle it differently. I don't know.

Either way, it should probably be noted in the docs, as you say.

steverice commented 9 years ago

Indeed; it may also be helpful for plugin authors to clarify the intent so there isn't that sort of inconsistency among implementations.

xuhdev commented 9 years ago

All plugins I can remember trim all lines. Do you know any plugins which do differently?

jednano commented 9 years ago

No, but I've only used the VS and Sublime ones.

atwellpub commented 9 years ago

Notepad++ doesn't have an option to trim lines on save. A new macro has to be created. Not sure what to do.

jednano commented 9 years ago

@atwellpub if that's a feature that's important to you have you considered using an editor that has support for that setting? I know that SublimeText has it and I'm sure others.

atwellpub commented 9 years ago

Sublime text does provide this feature already, but being a PHP developer I am very hapily dependent on Notepad++'s quick-nav function parser, which I can't find for sublime anywhere.

jednano commented 9 years ago

@atwellpub by no means am I telling you what to use, but have you considered PHPStorm? I'm willing to bet it has that feature. The people at JetBrains know what they are doing!

atwellpub commented 9 years ago

I have done a small investigation and have not found that feature. I will gladly switch to an editor that provides me with both.

Hopefully someone using PHPStorm will chime in.

xuhdev commented 9 years ago

but ... writing a macro isn't that hard?

denofevil commented 9 years ago

PhpStorm can do that: https://www.jetbrains.com/phpstorm/help/viewing-structure-of-a-source-file.html (not only for php)

jednano commented 9 years ago

@xuhdev I agree that writing a macro for Notepad++ shouldn't be hard, but I don't have any experience doing that in Notepad++, so I don't have much to offer.

It does seem that Alt+Shift+S in Notepad++ will trim trailing whitespace, but remembering to do that isn't terribly convenient, is it? It should be automated and bound to the EditorConfig setting.

I still think considering other editors might be the best viable option for @atwellpub, because of the features he deems important. @atwellpub, I can tell you that I've extensively used all 3 of the editors mentioned (Notepad++, PHPStorm and SublimeText 2/3) as well as Visual Studio. The important thing is to use the tool you find makes yourself the most productive. Based on what you need, it sounds like PHPStorm might be the right tool for you.

aweibell commented 8 years ago

I definitely would prefer having the three options that IntelliJ IDEA natively provides for what they name "Strip trailing spaces on save":

Trailing spaces should not appear in code, but when I modify others code, I don't want my commit to include lots of white space corrections. It makes it way harder to see in a quick diff what real code changes I did.

jednano commented 8 years ago

I agree that there would be value in a modified setting:

[*]
trim_trailing_whitespace = modified

We can still use true for all lines and your None scenario above would be the existing default.

aweibell commented 8 years ago

@jedmao Exactly!

jaller94 commented 7 years ago

Issues in code editors: