If you find clang-format not enough configurable, you can use another solution, like uncrustify. For instance, configuring the breaking braces is either Linux, Stroustrup, Allman or GNU, period. There are a limited set of configurable options, the downside is that it might not suit your style well. clang-format file in your home): clang-format -style=""Ĭlang-format is very promising, and easy to use. If you prefer, you can specify your options style directly in the workflow (instead of relying on the. Now, select some code in Xcode, right-click and select clang-format: For instance: # We’ll use defaults from the LLVM style, but with 4 columns indentation. clang-format file in your home directory and write your options. Select ’Output replaces selected text’ and save under the name ’clang-format’Ĭreate a.In the shell script box, write this command: export PATH=/usr/local/bin:$PATH Select ’Run Shell Script’ from the Library.Launch Automator, click on ’Services’, then ’Choose’.Then, we’re going to write a text services that will use clang-format to format a text selection: The easiest way is using Homebrew: $ brew install clang-format Now, we can use this method to write a service that will take text selection as input, and replace with it formatted output,įirst, we need to install clang-format on our system. We’ve seen how to write text services in Automator to extend Xcode text features. # We’ll use defaults from the LLVM style, but with 4 columns indentation. ![]() clang-format or _clang-format) in the folder of the source file, or recursively in the parent folder until it find a configuration file (this way, you can commit a configuration file to the root folder of your source project and have it shared by the whole team for a given project).Īn example of such configuration file:. You can base your clang-format configuration on these predefined style guides, and overrides some style options (see the complete list here).Ĭlang-format will search for a configuration file (named either.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |