[cmake-developers] Code style auto-formatting
Brad King
brad.king at kitware.com
Tue May 10 15:14:09 EDT 2016
On 05/09/2016 03:29 PM, Paul Smith wrote:
> On Mon, 2016-05-09 at 14:17 -0400, Brad King wrote:
>>> Where does 79 come from?
>>
>> That has been CMake's limit for a long time. Since we're changing the
>> style anyway we might as well go with the more common 80 chars
>
> Not to say whether or not this should be changed, but FYI the 79 comes
> from this set of facts:
>
> * Traditional terminals are 80 chars wide
> * Editors and viewers that do line-wrapping use the last character of
> the line to specify whether there was a wrap, otherwise you can't
> tell if the line is wrapped or there's a newline.
Thanks, Paul. Good explanation of the historical reason. I tend to
agree, but I wonder why this has not caused any of the standard
styles clang-format provides (Mozilla, Google, LLVM, etc.) to adopt
79 characters instead of 80. Maybe it is just that the width limit
is now more about supporting side-by-side diff views or multiple
terminal splits without using the entire monitor width for viewing
a source file with long lines. It also helps avoid excessive eye
movement horizontally while reading code. The difference between
79 and 80 characters for these purposes is negligible.
Only a small fraction of lines should end up near this limit so I
do not think readability will change much between 79 and 80 chars.
Therefore I propose that we go back to 79 characters for the above
reasons. It will also help `git diff` views fit in 80 chars even
with the left `+/-` column.
This brings us to:
---
# This configuration requires clang-format 3.8 or higher.
BasedOnStyle: Mozilla
AlignOperands: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
ColumnLimit: 79
Standard: Cpp03
...
-Brad
More information about the cmake-developers
mailing list