首页 > 其他分享 >vscode 自动修改C代码格式

vscode 自动修改C代码格式

时间:2023-06-28 21:47:06浏览次数:38  
标签:None false format vscode 代码 clang 格式 true 格式化

1.插件clang-format安装

 clang-format默认安装路径为c:\Users\wqr57\.vscode\extensions\ms-vscode.cpptools-0.18.1/bin/../LLVM/bin/clang-format.exe

 

2.C 格式客制化配置


---


Language: Cpp
# BasedOnStyle: LLVM


AccessModifierOffset: -4


AlignAfterOpenBracket: Align


AlignConsecutiveAssignments: true



AlignConsecutiveDeclarations: true


AlignConsecutiveBitFields: true

AlignConsecutiveMacros: true


AlignEscapedNewlines: Left


AlignArrayOfStructures: Left


#AlignEscapedNewlinesLeft: true


AlignOperands: true


AlignTrailingComments: true


AllowAllParametersOfDeclarationOnNextLine: false


AllowShortBlocksOnASingleLine: Empty


AllowShortCaseLabelsOnASingleLine: false


AllowShortFunctionsOnASingleLine: None


AllowShortIfStatementsOnASingleLine: Never


AllowShortLoopsOnASingleLine: false


AlwaysBreakAfterDefinitionReturnType: None


AlwaysBreakAfterReturnType: None


AlwaysBreakBeforeMultilineStrings: false


AlwaysBreakTemplateDeclarations: false


BinPackArguments: true


BinPackParameters: false


BraceWrapping:


AfterClass: false


AfterControlStatement: true


AfterCaseLabel: true


#BeforeCatch: true


AfterEnum: true


AfterFunction: true


AfterNamespace: false


AfterObjCDeclaration: false


AfterStruct: true


AfterUnion: true
AfterExternBlock: false



BeforeWhile: true


BeforeElse: true


IndentBraces: true
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false


BreakBeforeBinaryOperators: None


BreakBeforeBraces: Custom


BreakBeforeTernaryOperators: false


BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon


ColumnLimit: 80


CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false


ConstructorInitializerAllOnOneLineOrOnePerLine: false


ConstructorInitializerIndentWidth: 4


ContinuationIndentWidth: 4


Cpp11BracedListStyle: true


DerivePointerAlignment: true


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: true

IndentPPDirectives: None


IndentWidth: 4


IndentWrappedFunctionNames: false


KeepEmptyLinesAtTheStartOfBlocks: false


MacroBlockBegin: ''


MacroBlockEnd: ''


MaxEmptyLinesToKeep: 4


NamespaceIndentation: Inner


ObjCBlockIndentWidth: 4


ObjCSpaceAfterProperty: false


ObjCSpaceBeforeProtocolList: false


PenaltyBreakBeforeFirstCallParameter: 19


PenaltyBreakComment: 300


PenaltyBreakFirstLessLess: 120


PenaltyBreakString: 1000


PenaltyExcessCharacter: 1000000


PenaltyReturnTypeOnItsOwnLine: 60


PointerAlignment: Right


ReflowComments: false


SortIncludes: false


SpaceAfterCStyleCast: false

SpaceAfterTemplateKeyword: true


SpaceBeforeAssignmentOperators: true


SpaceBeforeParens: ControlStatements


SpaceInEmptyParentheses: false


SpacesBeforeTrailingComments: 2


SpacesInAngles: false


SpacesInContainerLiterals: false


SpacesInCStyleCastParentheses: false


SpacesInParentheses: false


SpacesInSquareBrackets: false


Standard: Cpp11


TabWidth: 4


UseTab: Never

 

 

3.问题

 客制化的.clang-format 没有生效

 (1).clang-formt 没生效

 设只快捷键格式化生效:CTRL+s

 2.修改.clang-format 文件,ctrl+s c文件格式化没生效

.clang-format 里添加了中文注释

 参考链接:

(177条消息) Clang-format格式化及配置参数_Once_day的博客-CSDN博客

使用clang-format格式化代码, 配置没有生效 - 简书 (jianshu.com)

(177条消息) VS Code C++ 代码格式化方法(clang-format)_c_cpp: clang_format_fallback style_core571的博客-CSDN博客

标签:None,false,format,vscode,代码,clang,格式,true,格式化
From: https://www.cnblogs.com/lzqd/p/17512494.html

相关文章

  • 案例-用户登录-代码实现
       代码实现packagecom.itheima.mapper;importcom.itheima.pojo.User;importorg.apache.ibatis.annotations.Param;importorg.apache.ibatis.annotations.Select;publicinterfaceUserMapper{@Select("select*fromtb_userwhereusername=#{use......
  • .NET Core 允许跨域的两种方式实现(IIS 配置、C# 代码实现)
    〇、前言当把开发好的WebApi接口,部署到Windows服务器IIS后,postman可以直接访问到接口并正确返回,这并不意味着任务完成,毕竟接口嘛是要有交互的,最常见的问题莫过于跨域了。若前端文件是在当前接口文件下的wwwroot文件夹下,那么接口的访问就没问题,因为是同协议(http、https)......
  • 格式转换
         ......
  • 零代码量化投资:用ChatGPT获取个股的实时行情数据
    在ChatGPT中输入提示词如下:实时行情数据-东财沪深京A股接口:stock_zh_a_spot_em目标地址: http://quote.eastmoney.com/center/gridlist.html#hs_a_board描述:东方财富网-沪深京A股-实时行情数据限量:单次返回所有沪深京A股上市公司的实时行情数据输入参数名称类型描述--......
  • centos之格式化输出 printf
    ############################对齐:右对齐:printf"%s"左对齐:printf"%-s"宽度:printf"%-10s" ,左对齐,宽度为10printf “%-4.2f” ,左对齐,宽度为4,保留两位小数。 格式化说明符:%s:字符串%d:数字%f:浮点数字%o:一个八进制的数字%x:一个十六进制的数字......
  • Spring 赌上未来一击,推出响应式框架 WebFlux,代码更优雅,性能更强!
    Spring-webflux简介spring-webflux是spring在5.0版本后提供的一套响应式编程风格的web开发框架,大量测评证明,使用WebFlux开发接口能够大幅提升接口的吞吐量。这个框架包含了spring-framework和springmvc,它可以运行在Netty、Undertow以及3.1版本以上的Serlvet容器上。你可以在项......
  • 基于Datainside无代码快速开发智慧城管系统
    基于Datainside平台进行无代码快速开发智慧城管系统,可以极大地提高开发效率,并实现功能丰富、易于维护的系统。下面我将详细描述基于Datainside的智慧城管系统开发过程。数据模型定义:首先,在Datainside平台上进行智慧城管系统的开发,需要根据实际需求定义数据模型。数据模型包......
  • (Python编程)集成代码生成器SWIG
    ProgrammingPython,3rdEdition翻译最新版本见:http://wiki.woodpecker.org.cn/moin/PP3eD22.6.TheSWIGIntegrationCodeGenerator22.6.集成代码生成器SWIGButdon'tdothat.Asyoucanprobablytell,manualcodingofCextensionscan......
  • Vscode自动生成注释的神器-KoroFileHeader
    1、安装KoroFileHeader设置-->扩展(ctrl+S)-->搜索KoroFileHeader,并安装 2、设置函数注释与文档注释设置—》搜索fileheaderconfiguration-》编辑setting.json文件设置自己的注释格式  //文件头注释"fileheader.customMade":{"Filename":"",......
  • maven 打包源代码
    前言maven"内置插件"中没有打包源代码的插件,所以,需要开发者配置插件。apache提供了maven-source-plugin插件用于打包源代码。maven-source-pluginTheSourcePluginhasfivegoals:source:aggregate aggregratessourcesforallmodulesinanaggregatorproject.source:jar i......