开发者

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

开发者_开发技巧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?


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.


Good old command line indent : http://linux.die.net/man/1/indent


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜