Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you set clang-format's line length?

Tags:

clang-format

clang-format is breaking up my lines at 80 columns. Is there a way to make stop breaking lines? The documentation doesn't seem to address this.

like image 265
Gregg Avatar asked Dec 06 '17 21:12

Gregg


People also ask

How do you customize your clang-format?

clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and put style configuration in the . clang-format or _clang-format file in the project directory.

Can clang-format break code?

Short answer: YES. The clang-format tool has a -sort-includes option. Changing the order of #include directives can definitely change the behavior of existing code, and may break existing code.

Does clang-format work for C?

clang-format is located in clang/tools/clang-format and can be used to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.


2 Answers

The configuration option responsible for it is called ColumnLimit. You can remove the column limit by setting it to 0.

ColumnLimit: 0 
like image 110
Paweł Bylica Avatar answered Sep 18 '22 09:09

Paweł Bylica


Find ColumnLimit (under "Configurable Format Style Options" heading) on that page and you'll find the following statement:

ColumnLimit (unsigned)

The column limit.

A column limit of 0 means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements unless they contradict other rules.

Source: Clang-Format Docs (v4.0.0, latest). Italics added for emphasis.

So, just like the docs say, set...

ColumnLimit: 0 

... and you should be set.

like image 30
ahogen Avatar answered Sep 20 '22 09:09

ahogen