课外小知识
Beautifier 是用来整理代码的小工具,一般要自己选择,我是在看Qt帮助的时候看到的,觉得有点意思,然后就做个记录备忘
这里我只用Qt做说明。,
1,先点帮助 ,进入关于插件
,
2,选中Beautifier上钩确定
3,点工具,进入选项
4 这里可以看到3种格式样本 Artistic Style, ClangFormat,Uncrustify
(2)Qt Creator主菜单-编辑-美化器
Clang Format配置界面里面,选择
D:\Qt\qtcreator-10.0.2\bin\clang\bin\ clang-format.exe
添加自定义风格:和公布自定义的配置一样也可以
5 Artistic Style 配置方式
可以百度收一下 Artistic Style
去网上下个安装包,解压放到知道目录
网站是http://astyle.sourceforge.net/
下载地址:http://sourceforge.net/projects/astyle/files/astyle/
我是放在D盘
点添加,我选的是自定义,Use customizd style
在value里面我填了下面的配置,仅供参考,要改的自己百度Artistic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | --recursive --style=allman --convert-tabs --indent=spaces=4 --attach-closing- while --indent-switches --indent-namespaces --indent-continuation=4 --indent-preproc-block --indent-preproc-define --indent-preproc-cond --indent-col1-comments --pad-oper --pad-header --unpad-paren -- delete -empty-lines --align-pointer=name --align-reference=name --add-braces --pad-comma --unpad-paren --add-one-line-braces --attach- return -type-decl --attach- extern -c --min-conditional-indent=2 --max-continuation-indent=40 --max-code-length=100 -- break -after-logical |
格式 Clang Format
这个同样去网上找个安装包
百度Clang Format 下面是下载界面
我用的是最新的,win64的,下载下来有的会报病毒,请强制信任安装,没事。
参考前面选中 clang-format.exe命令程序
也是有两种选择,自带的或者自定义的
我这里公布一下自定义的配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | AccessModifierOffset: -4 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: true AlignEscapedNewlinesLeft: true AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: Empty AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: false BinPackArguments: true BinPackParameters: true BraceWrapping: AfterClass: true AfterControlStatement: true AfterEnum: true AfterFunction: true AfterNamespace: true AfterObjCDeclaration: true AfterStruct: true AfterUnion: true BeforeCatch: true BeforeElse: true IndentBraces: false BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: Custom BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: true ColumnLimit: 200 CommentPragmas: '^ IWYU pragma:' ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 - Regex: '^(<|"(gtest|isl|json)/)' Priority: 3 - Regex: '.*' Priority: 1 IndentCaseLabels: false IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: Inner ObjCBlockIndentWidth: 4 ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left ReflowComments: true SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: true SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 TabWidth: 4 UseTab: Never |
具体什么意思参考 他 clang-format的介绍和使用 - Tudou_Blog - 博客园 (cnblogs.com)
格式 uncrustify
百度下载uncrustify
http://uncrustify.sourceforge.net
Uncrustify Code Beautifier - Browse Files at SourceForge.net
选个最新款下载
这里我就选他自带的配置了
这个勾选的话保存的时候回自动把代码整理好。下面是选择的整理格式工具,我这里就不勾选了
添加格式的快捷方式
环境,键盘,Format,
点一下Record,就可以记录快捷方式了,注意如果是红色,那就表示已经被其他地方注册了,换一个快捷方式
到此结束感谢观看。
本文来自博客园,作者:七星落地,转载请注明原文链接:https://www.cnblogs.com/dwx-bzdcxy/p/16788923.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具