GithubHelp home page GithubHelp logo

lehom / clangformat-xcode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from travisjeffery/clangformat-xcode

0.0 2.0 0.0 23.62 MB

Xcode plug-in to to use clang-format from in Xcode and consistently format your code with Clang

Home Page: https://twitter.com/travisjeffery

License: MIT License

Objective-C 100.00%

clangformat-xcode's Introduction

ClangFormat-Xcode

An Xcode plug-in to format your code using Clang's format tools, by @travisjeffery.

With clang-format you can use Clang to format your code to styles such as LLVM, Google, Chromium, Mozilla, WebKit, or your own configuration.

usage

demo

Installation:

Install via Alcatraz.

OR

Clone this repo, build and run ClangFormat, restart Xcode.

Usage:

Format on save

I.e., you press command-s and the file is formatted and wrote to disk.

In the menu, open Edit > Clang Format > Click Format on save (a checkmark appears in this menu item indicicating that the feature is active.)

Assign keyboard shortcuts

You can assign your own keyboard shortcuts like so:

  • Open the System Preferences > Keyboard > Shortcuts > App Shortcuts > Click +
  • Set the application to be Xcode
  • Set the menu title to an action title, e.g. "Format File in Focus"
  • Set your shortcut

In this example, we'll format the active file when control-i is pressed.

assign keyboard shortcut

Using your own style configuration

By using Clang Format > File in the plug-in menu, Clang will look for the nearest .clang-format file from the input file. Most likely, you'll have a .clang-format file at the root of your project.

Here are the options for .clang-format and how they're configured. Here's a cool interactive website to help you make your .clang-format file.

If one of the built-in styles is close to what you want, you can bootstrap your own configuration with:

./bin/clang-format -style=llvm -dump-config > .clang-format

For example, this .clang-format is similar to the Linux Kernel style:

BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Linux
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false

And this is similar to Visual Studio's style:

UseTab: Never
IndentWidth: 4
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0

clangformat-xcode's People

Contributors

antons avatar cojoj avatar florianbuerger avatar juhagman avatar masonmark avatar mkl-ableton avatar neonichu avatar prestonj avatar tonyarnold avatar travisjeffery avatar v01dzer0 avatar yeahphil avatar yixiang avatar zizicici avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.