任何自动缩进 ac/c++ 的方法使用 Kdevelop 编写代码?
我有一个不属于我的源代码,没有注释,也完全没有缩进。是不是真的很乱啊。你知道是否有一些选项,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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
假设您使用的是 KDevelop 4 而不是(不再支持)KDevelop 3...
您可以使用“Edit > Reformat Source”来格式化当前文件源。
您还可以右键单击左侧“项目”视图中的一个或多个文件,然后选择“格式化文件”
。您可以在“设置 > 配置 KDevelop > 源格式化程序”中配置源格式设置。
KDevelop 4 使用 AStyle 来处理格式。
编辑:
需要注意的是,“设置>配置编辑器”中还有一些设置可以配置嵌入的KatePart。
这些是“编辑时”设置,对上面详述的源格式组件没有影响。例如,这将控制在括号后插入换行符时的自动缩进。
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.
好的旧命令行缩进: http://linux.die.net/man/1/indent
Good old command line indent : http://linux.die.net/man/1/indent
在 KDevelop 中,如果我没记错的话,你可以转到“设置”->“设置”。配置->缩进。 (或类似的东西)。虽然我不记得这是否是您编写时自动缩进的设置,或者是否用于一般格式化代码。
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.
像 indent 这样的工具非常强大,但有大量的开关足以灵活地支持所有编码风格。
如果您需要的是一个编辑器,vim 可以很好地为 C 语言提供语法敏感的缩进。用 Vim 打开文件并执行“gg=G”即可完成。
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.