This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to set source code formatter line length?

I'm on macOS running  CCS 11.0.0.00006 (beta I guess, but IIRC I had the same problem with earlier versions).

When I press CMD + SHIFT + F to format my source code all the lines are wrapped at 80 column mark.

This is ridiculously low number of columns (Herman Hollerith died in 1929) and incompatible with company formatting rules.

Regardless what my co-patriot Linus insists.

So where can I change this, this is giving me gray hair.

Worse yet, a colleague working on the same project is using Windows and on his machine the lines are not wrapped at all automatically, which basically what I want.

wbr Kusti

  • Doesn't happen to me:

    pre-format

    post-format

    (Though it does put the declaration on one line and the initialization on another)

  • Kusti,

    The settings for this are buried in the formatter.  I always struggle to get these just right.  So be prepared to pull out some of that gray hair.

    Open the preferences dialog

    Click on link at the bottom to show advanced settings

    Then navigate to C/C++ -> Code Style -> Fomatter.

    Click the Edit button beside the active profile

    The formatter settings are quite complicated.  There is a tab for line wrapping.  There you can specify when you want things to wrap and when not to.  You can gett really specific.

    You might want to get agressive in turning off wrapping and you can select a category and the set it to never wrap any of the sub areas.  Here I selected Function parameters and then said do not wrap.  This will apply to all the variations underneath.

    There is also another wrapping option here:

    Regards,

    John

  • Here is an example:

    Formatter setting

    Result

    Where if I set to not wrap

    Setting

    Result

    Regards,

    John

  • Thanks!

    "Advanced Settings" was the piece of the puzzle that was missing! Feel so smart know ;) 

    Who in their right mind puts an "Advanced Settings" button into a tool for professional programmers.... argh, thanks Eclipse Foundation ;)