Use of Clang-format and its custom format

Source: Internet
Author: User
Tags sublime text

previously want to use the Clangformat plug-in to define the encoding format in Xcode, and then search the data on the Internet, after the installation of the custom format has been a problem, always error, and then the good people have, I met a big God on the internet to me to solve. Then I made a summary of my own use of Clangformat:

1. Download Clangformat in github, download address: Https://github.com/travisjeffery/ClangFormat-Xcode

2. Install: Open the downloaded Clangformat, compile it in Xcode, run it, and then restart Xcode

3. How to use: Click Edit->clangformat-> to choose the format you want

(select "Format Selected files" to format multiple files;

Select "Format file in Focus" to format the current file;

Select "Format Selected text" to format this paragraph of text;

You can also set the shortcut keys for these functions, specific I do not say, a search on the internet a lot, mainly speaking of the custom format when I encountered problems

4. Create a ". Clang-format" file in the project catalog or workspace directory, and add parameters similar to the following:

BASEDONSTYLE:LLVM indentwidth:4 maxemptylinestokeep:4 Breakbeforebraces:attach AllowShortIfStatementsOnASingleLine : True indentcaselabels: true objcblockindentwidth:4 objcspaceafterproperty: true columnlimit:0 aligntrailingcomments: true spaceaftercstylecast: true spacesinparentheses: False Spacesinsquarebrackets: false This is my current use of some parameters, I put these parameters in the text, and then save as ". Clang-format" in the root directory when the use of the error, The result is a hint from the great God that the parameters are edited with sublime text and then saved so that you can use your own defined format.

5. Finally select "File" in the "Edit", "Clang format" of Xcode and let the penultimate line show "Disable format on Save". This allows you to customize the encoding format.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.