• vscode clang-format


    1. 安装 clang-format 插件

    2. 在项目目录下新建 .clang-format 文件

    3. 参考 https://code.visualstudio.com/docs/cpp/cpp-ide#_code-formatting

    .clang-format :

    # Copyright (c) 2020 vesoft inc. All rights reserved.
    #
    # This source code is licensed under Apache 2.0 License,
    # attached with Common Clause Condition 1.0, found in the LICENSES directory.
    #
    # This is the output of clang-format-7.0 --style=google --dump-config,
    # except for changes mentioned below.
    # We have locked the version of clang-format in order to avoid inconsistencies
    # in the format caused by developers using different clang-format versions.
    ---
    Language:        Cpp
    # BasedOnStyle:  Google
    AlignAfterOpenBracket: Align
    AlignConsecutiveDeclarations: false
    AlignOperands:   true
    AlignTrailingComments: true
    AllowShortBlocksOnASingleLine: false
    AllowShortCaseLabelsOnASingleLine: false
    AllowShortIfStatementsOnASingleLine: true
    AllowShortLoopsOnASingleLine: true
    AlwaysBreakAfterDefinitionReturnType: None
    AlwaysBreakAfterReturnType: None
    AlwaysBreakTemplateDeclarations: Yes
    BraceWrapping:
      AfterClass:      false
      AfterControlStatement: false
      AfterEnum:       false
      AfterFunction:   false
      AfterNamespace:  false
      AfterObjCDeclaration: false
      AfterStruct:     false
      AfterUnion:      false
      AfterExternBlock: false
      BeforeCatch:     false
      BeforeElse:      false
      IndentBraces:    false
      SplitEmptyFunction: true
      SplitEmptyRecord: true
      SplitEmptyNamespace: true
    BreakBeforeBinaryOperators: None
    BreakBeforeBraces: Attach
    BreakBeforeInheritanceComma: false
    BreakInheritanceList: BeforeColon
    BreakBeforeTernaryOperators: true
    BreakConstructorInitializersBeforeComma: false
    BreakConstructorInitializers: BeforeColon
    BreakAfterJavaFieldAnnotations: false
    BreakStringLiterals: true
    CommentPragmas:  '^ IWYU pragma:'
    CompactNamespaces: false
    ConstructorInitializerAllOnOneLineOrOnePerLine: true
    ConstructorInitializerIndentWidth: 4
    ContinuationIndentWidth: 4
    Cpp11BracedListStyle: true
    DerivePointerAlignment: true
    DisableFormat:   false
    ExperimentalAutoDetectBinPacking: false
    FixNamespaceComments: true
    ForEachMacros:
      - foreach
      - Q_FOREACH
      - BOOST_FOREACH
    IncludeBlocks:   Preserve
    IncludeCategories:
      - Regex:           '^<ext/.*.h>'
        Priority:        2
      - Regex:           '^<.*.h>'
        Priority:        1
      - Regex:           '^<.*'
        Priority:        2
      - Regex:           '.*'
        Priority:        3
    IncludeIsMainRegex: '([-_](test|unittest))?$'
    IndentCaseLabels: true
    IndentPPDirectives: None
    IndentWrappedFunctionNames: false
    JavaScriptQuotes: Leave
    JavaScriptWrapImports: true
    KeepEmptyLinesAtTheStartOfBlocks: false
    MacroBlockBegin: ''
    MacroBlockEnd:   ''
    MaxEmptyLinesToKeep: 1
    NamespaceIndentation: None
    ObjCBinPackProtocolList: Never
    ObjCSpaceAfterProperty: false
    ObjCSpaceBeforeProtocolList: true
    PenaltyBreakAssignment: 2
    PenaltyBreakBeforeFirstCallParameter: 1
    PenaltyBreakComment: 300
    PenaltyBreakFirstLessLess: 120
    PenaltyBreakString: 1000
    PenaltyBreakTemplateDeclaration: 10
    PenaltyExcessCharacter: 1000000
    PenaltyReturnTypeOnItsOwnLine: 200
    PointerAlignment: Left
    RawStringFormats:
      - Language:        Cpp
        Delimiters:
          - cc
          - CC
          - cpp
          - Cpp
          - CPP
          - 'c++'
          - 'C++'
        CanonicalDelimiter: ''
        BasedOnStyle:    google
      - Language:        TextProto
        Delimiters:
          - pb
          - PB
          - proto
          - PROTO
        EnclosingFunctions:
          - EqualsProto
          - EquivToProto
          - PARSE_PARTIAL_TEXT_PROTO
          - PARSE_TEST_PROTO
          - PARSE_TEXT_PROTO
          - ParseTextOrDie
          - ParseTextProtoOrDie
        CanonicalDelimiter: ''
        BasedOnStyle:    google
    ReflowComments:  true
    SortIncludes:    true
    SortUsingDeclarations: true
    SpaceAfterCStyleCast: false
    SpaceAfterTemplateKeyword: true
    SpaceBeforeAssignmentOperators: true
    SpaceBeforeCpp11BracedList: false
    SpaceBeforeCtorInitializerColon: true
    SpaceBeforeInheritanceColon: true
    SpaceBeforeParens: ControlStatements
    SpaceBeforeRangeBasedForLoopColon: true
    SpaceInEmptyParentheses: false
    SpacesInAngles:  false
    SpacesInContainerLiterals: true
    SpacesInCStyleCastParentheses: false
    SpacesInParentheses: false
    SpacesInSquareBrackets: false
    TabWidth:        4
    UseTab:          Never
    
    #Different from google style
    Standard:        Cpp11
    AccessModifierOffset: -4
    AllowAllParametersOfDeclarationOnNextLine: false
    ColumnLimit:     100
    ObjCBlockIndentWidth: 4
    AlignEscapedNewlines: Right
    AlwaysBreakBeforeMultilineStrings: false
    BinPackArguments: false
    BinPackParameters: false
    IndentWidth:     4
    SpacesBeforeTrailingComments: 3
    AllowShortFunctionsOnASingleLine: Empty
    ...
    
  • 相关阅读:
    reaver 破解wifi
    CDOJ 1255 斓少摘苹果 图论 2016_5_14
    CDOJ 1256 打表+数组 统计
    poj 3190 贪心+优先队列优化
    poj 2376 Cleaning Shifts 贪心 区间问题
    poj 3253 Fence Repair 贪心
    poj 3069 贪心+区间问题
    poj 3050 Hopscotch DFS+暴力搜索+set容器
    poj 2718 Smallest Difference(暴力搜索+STL+DFS)
    poj 3187 Backward Digit Sums
  • 原文地址:https://www.cnblogs.com/mangoczp/p/14593227.html
Copyright © 2020-2023  润新知