[cfe-users] clang-format: Preserve horizontal whitespace?

Michael Wünsch liganic-clang at gmx.org
Tue Jun 17 01:04:32 PDT 2014


How hard would it to implement this? I'd take a stab at it if somebody
could point me in the right direction.
It's currently the only thing from stopping us to run clang-format as a
pre-commit.

> On 14/06/14 22:18, Seth Cantrell wrote:
> There's no option for this at the moment. I believe what you'd really
> want, however, is an option to automatically align variable
> initializers similar to how certain comments get aligned.
> 
>> On Jun 14, 2014, at 3:59 PM, "Michael Wünsch" <liganic-clang at gmx.org> wrote:
>>
>> Hey everyone,
>> I'm trying to get clang-format to preserve horizontal whitespace. For
>> example:
>>
>> void main() {
>>  int FOO       = 1;
>>  int BAR       = 2;
>>  int VERY_LONG = 3;
>> }
>>
>> gets mushed into (using -style=Google as an example):
>> void main() {
>>  int FOO = 1;
>>  int BAR = 2;
>>  int VERY_LONG = 3;
>> }
>>
>> The (Google) Styleguide
>> (https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml) says:
>>
>> "// Assignment operators always have spaces around them."
>>
>> This means at least one, not exactly one. clang-format however always
>> consumes all horizontal whitespace and merges it into one space.
>>
>> Is there any way to fix this?
>>
>> Regards,
>> --
>> Michael
>> _______________________________________________
>> cfe-users mailing list
>> cfe-users at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users



More information about the cfe-users mailing list