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?
4 Answers
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.

- 2,650
- 1
- 16
- 15
-
You can configure the way this feature works by going under `Settings > Configure KDevelop...` and selecting `Source Formatter` on the left. – Octopus Aug 09 '14 at 00:29
-
Thanks. Life safer. For me I had to put the style to Artistic Style to be working. – stephanmg Apr 08 '20 at 16:56
Good old command line indent : http://linux.die.net/man/1/indent

- 6,247
- 1
- 17
- 34
-
1+1: I'd just like it to be able to keep the `{` on the same line as `main` – pmg May 05 '11 at 18:42
-
cool, unfortunately now I've not enough time to read the options so I'll try some GUI tool.. but I'll try it later on.. THx! – manty May 05 '11 at 18:49
In KDevelop if I remember correctly you can go to Settings -> Configure -> Indentation. (Or something similar). Though I can't remember if that's settings for Auto-Indentation as you write or whether its for formatting code in general.

- 51
- 3
Tools like indent are quite powerful but has tons of switches to be flexible enough to support all coding style.
If it's an editor you're after, vim does syntax-sensitive indention for C nicely. Open the file with Vim and do "gg=G" and you're done.

- 11,433
- 18
- 83
- 133