Any way to auto-indent a c/c++ code with Kdevelop?

manty picture manty · May 5, 2011 · Viewed 11.4k times · Source

I've a source code that's not mine, there are not comment and it's completely not indented. Is it a really mess. Do you know if there is some option, addon for kdevelop that would auto-indent it?

Answer

OliJG picture OliJG · Jun 4, 2011

Assuming you're using KDevelop 4 and not the (no longer supported) KDevelop 3...

You can use "Edit > Reformat Source" to format the current file source.

You can also right click on one or more files in Projects view on the left and select "Format Files"

You can configure your source formatting settings in "Settings > Configure KDevelop > Source Formatter".

KDevelop 4 uses AStyle to handle the formatting.

Edit: It should be noted that there are also some settings in "Settings > Configure Editor" which configures the embedded KatePart.
These are the "as you edit" settings with no effect on the source formatting component detailed above. This would control the auto-indentation when inserting newlines after a bracket, for example.