Our code review tool shows trailing whitespace in red. I should make sure our git is configured to complain about commits that include new/changed lines containing trailing whitespace. My editor is configured to make trailing whitespace visible. But, no, I don't have it automatically strip such. But I do often strip all trailing whitespace.

One reason to not unconditionally strip whitespace has to do with merge conflicts, so I will usually commit whitespace changes in a separate commit from any other changes. Once bitten by having to spend hours on a merge conflict due to extensive whitespace changes interfering with automated merge resolution, twice shy. :)

But if you don't have to worry about that case, I have a hard time coming up with a compelling argument against automated removal of trailing whitespace.

I've long advocated not using chomp but instead doing s/\s+$// because trailing whitespace should never matter (it also helps avoid problems with unexpected \r characters, which also shouldn't matter).

When composing my prior node, I recalled being worried that the C preprocessor might not properly handle an at-line-end \ if it is followed by a space. I did a quick test and the first cpp I ran across didn't have that bug. But I'm not surprised if other (especially earlier) versions did.

- tye        


In reply to Re^10: Quote and Quote-like Operators (trailing space) by tye
in thread Quote and Quote-like Operators by Xiong

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.