How to auto indent a C++ class with 4 spaces using clang-format?

后端 未结 3 822
北荒
北荒 2021-02-01 03:13

I got the next .clang-format file in my project\'s root directory:

---
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatements         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 03:47

    I met the same problems, and find the quickest solution is to make a copy of clang default setting(found by Preference -> Package Settings -> Clang Format -> Custom Style-Default) into the user custom setting(Preference -> Package Settings -> Clang Format -> Custom Style - User), then uncomment and modify some options into your own preference. For Example:

    "ColumnLimit": 119,
    // Indent width for line continuations.
    "ContinuationIndentWidth": 4,
    // The number of columns to use for indentation.
    "IndentWidth": 4,
    "TabWidth": 4,
    "UseTab": "Never"
    

提交回复
热议问题