ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Clang Format

by rosshemsley ST3

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

Labels formatting, clang, c, c++

Details

Installs

  • Total 57K
  • Win 21K
  • Mac 14K
  • Linux 22K
May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5
Windows 5 5 4 4 1 1 4 7 2 2 2 1 4 3 3 2 2 2 1 4 4 2 3 5 3 1 3 2 8 3 2 2 2 3 4 4 5 2 2 4 1 3 6 2 7 4
Mac 0 2 2 3 0 0 3 0 1 1 0 2 2 2 3 0 1 1 3 1 1 4 1 2 0 2 2 1 0 1 1 1 3 1 0 1 3 0 3 0 0 0 3 3 2 2
Linux 1 1 4 2 1 1 0 3 3 3 5 1 0 7 6 2 0 4 1 0 4 5 0 3 3 3 3 2 1 2 4 3 3 1 1 1 3 1 1 5 3 5 2 3 2 3
0510May 20May 17May 14May 11May 8May 5May 2Apr 29Apr 26Apr 23Apr 20Apr 17Apr 14Apr 11Apr 8Apr 5May 20 Linux: 1 Mac: 0 Windows: 5May 19 Linux: 1 Mac: 2 Windows: 5May 18 Linux: 4 Mac: 2 Windows: 4May 17 Linux: 2 Mac: 3 Windows: 4May 16 Linux: 1 Mac: 0 Windows: 1May 15 Linux: 1 Mac: 0 Windows: 1May 14 Linux: 0 Mac: 3 Windows: 4May 13 Linux: 3 Mac: 0 Windows: 7May 12 Linux: 3 Mac: 1 Windows: 2May 11 Linux: 3 Mac: 1 Windows: 2May 10 Linux: 5 Mac: 0 Windows: 2May 9 Linux: 1 Mac: 2 Windows: 1May 8 Linux: 0 Mac: 2 Windows: 4May 7 Linux: 7 Mac: 2 Windows: 3May 6 Linux: 6 Mac: 3 Windows: 3May 5 Linux: 2 Mac: 0 Windows: 2May 4 Linux: 0 Mac: 1 Windows: 2May 3 Linux: 4 Mac: 1 Windows: 2May 2 Linux: 1 Mac: 3 Windows: 1May 1 Linux: 0 Mac: 1 Windows: 4Apr 30 Linux: 4 Mac: 1 Windows: 4Apr 29 Linux: 5 Mac: 4 Windows: 2Apr 28 Linux: 0 Mac: 1 Windows: 3Apr 27 Linux: 3 Mac: 2 Windows: 5Apr 26 Linux: 3 Mac: 0 Windows: 3Apr 25 Linux: 3 Mac: 2 Windows: 1Apr 24 Linux: 3 Mac: 2 Windows: 3Apr 23 Linux: 2 Mac: 1 Windows: 2Apr 22 Linux: 1 Mac: 0 Windows: 8Apr 21 Linux: 2 Mac: 1 Windows: 3Apr 20 Linux: 4 Mac: 1 Windows: 2Apr 19 Linux: 3 Mac: 1 Windows: 2Apr 18 Linux: 3 Mac: 3 Windows: 2Apr 17 Linux: 1 Mac: 1 Windows: 3Apr 16 Linux: 1 Mac: 0 Windows: 4Apr 15 Linux: 1 Mac: 1 Windows: 4Apr 14 Linux: 3 Mac: 3 Windows: 5Apr 13 Linux: 1 Mac: 0 Windows: 2Apr 12 Linux: 1 Mac: 3 Windows: 2Apr 11 Linux: 5 Mac: 0 Windows: 4Apr 10 Linux: 3 Mac: 0 Windows: 1Apr 9 Linux: 5 Mac: 0 Windows: 3Apr 8 Linux: 2 Mac: 3 Windows: 6Apr 7 Linux: 3 Mac: 3 Windows: 2Apr 6 Linux: 2 Mac: 2 Windows: 7Apr 5 Linux: 3 Mac: 2 Windows: 4May 20 Linux: 1 Mac: 0 Windows: 5May 19 Linux: 1 Mac: 2 Windows: 5May 18 Linux: 4 Mac: 2 Windows: 4May 17 Linux: 2 Mac: 3 Windows: 4May 16 Linux: 1 Mac: 0 Windows: 1May 15 Linux: 1 Mac: 0 Windows: 1May 14 Linux: 0 Mac: 3 Windows: 4May 13 Linux: 3 Mac: 0 Windows: 7May 12 Linux: 3 Mac: 1 Windows: 2May 11 Linux: 3 Mac: 1 Windows: 2May 10 Linux: 5 Mac: 0 Windows: 2May 9 Linux: 1 Mac: 2 Windows: 1May 8 Linux: 0 Mac: 2 Windows: 4May 7 Linux: 7 Mac: 2 Windows: 3May 6 Linux: 6 Mac: 3 Windows: 3May 5 Linux: 2 Mac: 0 Windows: 2May 4 Linux: 0 Mac: 1 Windows: 2May 3 Linux: 4 Mac: 1 Windows: 2May 2 Linux: 1 Mac: 3 Windows: 1May 1 Linux: 0 Mac: 1 Windows: 4Apr 30 Linux: 4 Mac: 1 Windows: 4Apr 29 Linux: 5 Mac: 4 Windows: 2Apr 28 Linux: 0 Mac: 1 Windows: 3Apr 27 Linux: 3 Mac: 2 Windows: 5Apr 26 Linux: 3 Mac: 0 Windows: 3Apr 25 Linux: 3 Mac: 2 Windows: 1Apr 24 Linux: 3 Mac: 2 Windows: 3Apr 23 Linux: 2 Mac: 1 Windows: 2Apr 22 Linux: 1 Mac: 0 Windows: 8Apr 21 Linux: 2 Mac: 1 Windows: 3Apr 20 Linux: 4 Mac: 1 Windows: 2Apr 19 Linux: 3 Mac: 1 Windows: 2Apr 18 Linux: 3 Mac: 3 Windows: 2Apr 17 Linux: 1 Mac: 1 Windows: 3Apr 16 Linux: 1 Mac: 0 Windows: 4Apr 15 Linux: 1 Mac: 1 Windows: 4Apr 14 Linux: 3 Mac: 3 Windows: 5Apr 13 Linux: 1 Mac: 0 Windows: 2Apr 12 Linux: 1 Mac: 3 Windows: 2Apr 11 Linux: 5 Mac: 0 Windows: 4Apr 10 Linux: 3 Mac: 0 Windows: 1Apr 9 Linux: 5 Mac: 0 Windows: 3Apr 8 Linux: 2 Mac: 3 Windows: 6Apr 7 Linux: 3 Mac: 3 Windows: 2Apr 6 Linux: 2 Mac: 2 Windows: 7Apr 5 Linux: 3 Mac: 2 Windows: 4May 20 Linux: 1 Mac: 0 Windows: 5May 19 Linux: 1 Mac: 2 Windows: 5May 18 Linux: 4 Mac: 2 Windows: 4May 17 Linux: 2 Mac: 3 Windows: 4May 16 Linux: 1 Mac: 0 Windows: 1May 15 Linux: 1 Mac: 0 Windows: 1May 14 Linux: 0 Mac: 3 Windows: 4May 13 Linux: 3 Mac: 0 Windows: 7May 12 Linux: 3 Mac: 1 Windows: 2May 11 Linux: 3 Mac: 1 Windows: 2May 10 Linux: 5 Mac: 0 Windows: 2May 9 Linux: 1 Mac: 2 Windows: 1May 8 Linux: 0 Mac: 2 Windows: 4May 7 Linux: 7 Mac: 2 Windows: 3May 6 Linux: 6 Mac: 3 Windows: 3May 5 Linux: 2 Mac: 0 Windows: 2May 4 Linux: 0 Mac: 1 Windows: 2May 3 Linux: 4 Mac: 1 Windows: 2May 2 Linux: 1 Mac: 3 Windows: 1May 1 Linux: 0 Mac: 1 Windows: 4Apr 30 Linux: 4 Mac: 1 Windows: 4Apr 29 Linux: 5 Mac: 4 Windows: 2Apr 28 Linux: 0 Mac: 1 Windows: 3Apr 27 Linux: 3 Mac: 2 Windows: 5Apr 26 Linux: 3 Mac: 0 Windows: 3Apr 25 Linux: 3 Mac: 2 Windows: 1Apr 24 Linux: 3 Mac: 2 Windows: 3Apr 23 Linux: 2 Mac: 1 Windows: 2Apr 22 Linux: 1 Mac: 0 Windows: 8Apr 21 Linux: 2 Mac: 1 Windows: 3Apr 20 Linux: 4 Mac: 1 Windows: 2Apr 19 Linux: 3 Mac: 1 Windows: 2Apr 18 Linux: 3 Mac: 3 Windows: 2Apr 17 Linux: 1 Mac: 1 Windows: 3Apr 16 Linux: 1 Mac: 0 Windows: 4Apr 15 Linux: 1 Mac: 1 Windows: 4Apr 14 Linux: 3 Mac: 3 Windows: 5Apr 13 Linux: 1 Mac: 0 Windows: 2Apr 12 Linux: 1 Mac: 3 Windows: 2Apr 11 Linux: 5 Mac: 0 Windows: 4Apr 10 Linux: 3 Mac: 0 Windows: 1Apr 9 Linux: 5 Mac: 0 Windows: 3Apr 8 Linux: 2 Mac: 3 Windows: 6Apr 7 Linux: 3 Mac: 3 Windows: 2Apr 6 Linux: 2 Mac: 2 Windows: 7Apr 5 Linux: 3 Mac: 2 Windows: 4

Readme

Source
raw.​githubusercontent.​com

Clang Format

What it does

Clang-format is a tool for 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 here, 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 clang-format in one of the following ways:
    • Install using your package manager, e.g. sudo apt-get install clang-format or sudo apt-get install clang-format-5.0.
    • Download the entire LLVM toolchain and extract the clang-format binary. Just extract the .tar.xz file and copy bin/clang-format into your PATH (e.g. /usr/local/bin).
  • Install this package through Package Control in the usual way.
  • 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 option+cmd+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 run the formatter on every save to a file, change settings to "format_on_save": true.
  • To run the formatter in one stroke, press ctrl+e for windows and linux or super+e for OSX. You can always change the keybinding in the keymap to your liking.
  • To change settings on a per-package basis, add them under ClangFormat key, example project.sublime-settings:
{
  "folders": [],
  "settings": {
    "ClangFormat": {
      "format_on_save": true
    }
  }
}

If You Liked This

  • … And want to contribute, PR's gladly accepted!

  • Maybe you'll like my other plugin, iOpener. It lets you open files by path, with completion, history, and other goodies.

  • Otherwise, why not pop on 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, Bendtherules and other contributors 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