问题描述
有很多源代码格式化工具。哪些最适合C ++?
There are lots of source code formatting tools out there. Which ones work best for C++?
我对命令行工具或其他可以在检查代码时自动运行的东西感兴趣,最好不需要启动编辑器或IDE。
I'm interested in command-line tools or other things that can be automatically run when checking code in/out, preferably without needing to launch an editor or IDE.
(如果您看到已经列出的答案,请将其投票,如果没有,请添加。)
(If you see the one you like already listed as an answer, vote it up. If it's not there, add it.)
推荐答案
这是一个源代码格式化工具。
This is a source code formatting tool.
是
它可以与Visual的集成在一起,它可以与强大的命令行工具捆绑在一起, Studio,Emacs,Vim(和其他),并且可以格式化所选行(或使用git / svn格式化一些diff)。
It can be integrated with Visual Studio, Emacs, Vim (and others) and can format just the selected lines (or with git/svn to format some diff).
列出的选项。
当使用配置文件(名为 .clang-format
)时,样式可以是每个目录 - 父目录中最接近的文件应用于特定文件。
When using config files (named .clang-format
) styles can be per directory - the closest such file in parent directories shall be used for a particular file.
样式可以从预设(例如LLVM或Google)继承,然后可以覆盖不同的选项
Styles can be inherited from a preset (say LLVM or Google) and can later override different options
另请参阅项目。您可以使用它来实验几个缩进:AStyle,Uncrustify,GreatCode,...并选择最适合你。以后可以从命令行运行它们。
Also look at the project UniversalIndentGUI. You can experiment with several indenters using it: AStyle, Uncrustify, GreatCode, ... and select the best for you. Any of them can be run later from a command line.
有一个批次可配置选项。你可能需要通用缩进GUI(在Konstantin的回复)以及配置它。
Uncrustify has a lot of configurable options. You'll probably need Universal Indent GUI (in Konstantin's reply) as well to configure it.
这篇关于最好的C ++代码格式化/美化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!