Format C/C++ code on save Format C/C++ code on save c c

Format C/C++ code on save


I know about the "Format on save" option in Java editor, but I could not find one in C/C++ ... Or maybe I haven't looked enough?

I'm afraid that option is simply not available for the CDT C++ editor (Eclipse CDT Juno Service Release 1):

Eclipse Juno C++ CDT Text Editor Save Action Options

That's everything that's available at Eclipses IDE Level.

There are two solutions you might consider to solve your concerns:

  1. You might consider adopting some discipline as mentioned in the other answers
  2. Running an appropriate script to format your source files before committing them. The AStyle tool might be helpful for this purpose.

One could also think about an automatic pre-checkin/-commit interception running a script for the actually used Revision Control System. Many revision/version control systems offer such feature.

May I expect to see such option one day?

Did you ask for this feature on the Eclipse/CDT community forum, or placed a feature request in the Eclipse CDT bugzilla tracking system? If no one knows about such feature demand and whether it is demanded by a majority of users, chances that this will be implemented by 'accident' are low.


You can use the keys "Ctrl+Shift+F" to format your edited c/c++ file.


Format on save in CDT is now implemented in Eclipse Mars.