GithubHelp home page GithubHelp logo

gro00 / sublimeclangformat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rosshemsley/sublimeclangformat

0.0 1.0 0.0 308 KB

A C++ code formatter based on Clang Format, for beautiful code with minimal effort in Sublime Text 3

License: Other

JavaScript 63.45% Python 36.55%

sublimeclangformat's Introduction

Clang Format

Updates: Preliminary support for Javascript has been added! Update to latest version of clang-format provided with LLVM 3.5 to avoid known bugs.

What it does

Clang-format is a tool for re-formatting C++, built on LLVM. This is a package that allows you to run it easily from within Sublime Text.

demo

About

In this package, we provide an alternative wrapper around clang-format for use within Sublime Text 3. Whilst LLVM does provide a very simple plugin to work with Sublime Text already: https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format-sublime.py, it doesn't really exploit any of the Sublime Text package functionality. We add new features such as customising the style from a settings file, selecting styles using the Command Palette, and easier installation.

Installing

  • Install this package through Package Control in the usual way.

  • Get the clang-format binary for your platform. All binaries provided below are from the LLVM 3.5 release. They are for 64-bit platforms only:

    If you prefer, you can download the entire LLVM toolchain and extract the clang-format binary yourself. Just extract the .tar.xz file and copy bin/clang-format into your PATH (e.g. /usr/local/bin).

  • Set the path to the clang-format binaries. You can do this from within Sublime Text by choosing Clang Format - Set Path from the command palette. Hint: the path should look something like this [path/to/clang]/clang/bin/clang-format. If clang-format is in your system path, you shouldn't need to do anything.

Use

  • Default shortcut is super+option+a on OSX and ctrl+option+a otherwise. This will apply clang-format to the selection.
  • From the command palette, you can select the formatting type by using Clang Format: Select Style. You will find the small number of defaults, and also a new 'Custom' entry. Selecting this entry allows you to customise the style through a settings file. You can access it from the main menu, under Package Settings. In this file you can add custom rules, such as Allmen style braces, and different indents. For examples see http://clang.llvm.org/docs/ClangFormatStyleOptions.html.
  • Settings for the 'Custom' format and others are available through the Sublime Text preferences.
  • It is possible to enable the formatter on every save to a C/C++ file. To change settings on a per-package basis, check out the package "Project-Specific".

If You Liked This

If you like this plugin, maybe you'll like my other plugin, iOpener. It makes opening files significantly easier and will feel completely natural if you're used to using a shell. Otherwise, why not pop over and star this repo on GitHub?

Credits

Thanks to the LLVM project for doing the hard work, including writing clang format, and also the original Sublime Text plugin on which this package is based.

Also thanks to y0ssar1an and Bendtherules for their improvements!

Finally

Why not go and watch the video that got me interested in clang-format in the first place?

The Care and Feeding of C++'s Dragons

sublimeclangformat's People

Contributors

rosshemsley avatar ryboe avatar bblanchon avatar

Watchers

James Cloos 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.