CW Holeman II
CW Holeman II

Reputation: 4961

Customize Eclipse CDT to use Ratliff style for auto formatting

How to customize Eclipse CDT to use Ratliff style for auto formatting?

Ratliff Style of formating code indents the terminating brace to the same level as the contents of the block:

 for (i = 0; i < 10; i++) {
     if (i % 2 == 0) {
         doSomething(i);
         }
     else {
          doSomethingElse(i);
         }
     }

Eclipse CDT allows a number of common styles to be selected for auto formatting. Ratliff is not in the list but you can modify them to meet your specific requirements:

Eclipse CDT Formatter Edit

except there is no option in the list of choices to have the end brace align with the block contents:

Options for braaces

Upvotes: 1

Views: 196

Answers (1)

HighCommander4
HighCommander4

Reputation: 52799

No one has implemented this option in CDT's formatter.

CDT is open source, you're welcome to contribute a patch that implements it.

However, given how little CDT's formatter is maintained in general these days, a better use of your time might be to contribute support for the Ratcliff style to clang-format (which also doesn't currently support it, as far as I can tell), and use clang-format in CDT via a plugin like CppStyle.

Upvotes: 1

Related Questions