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

Sublime​AStyle​Formatter

by timonwong ALL

C/C++/C#/Java code formatter/beautifier with AStyle.

Labels formatting

Details

Installs

  • Total 152K
  • Win 87K
  • Mac 29K
  • Linux 36K
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 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6
Windows 1 16 12 17 15 18 12 12 14 14 14 19 19 14 11 13 14 19 15 16 41 11 21 25 24 18 29 11 13 22 26 17 29 22 12 25 28 18 20 26 19 16 16 12 19 23
Mac 1 9 3 3 5 11 4 5 2 5 4 9 3 5 3 5 8 4 5 5 3 8 8 6 4 2 2 4 2 9 6 5 6 9 4 12 6 1 8 9 4 1 5 7 4 3
Linux 0 2 4 3 3 3 1 0 3 5 3 2 1 2 6 2 3 2 2 5 3 4 5 8 1 7 0 4 3 5 5 4 5 3 3 1 7 6 6 4 1 6 4 6 5 5

Readme

Source
raw.​githubusercontent.​com

Sublime Text 2 & 3 AStyle Formatter Plugin

AppVeyor Build Status

Description

SublimeAStyleFormatter is a simple code formatter plugin for Sublime Text. It provides ability to format C, C++, Cuda-C++, OpenCL, Arduino, C#, and Java files.

NOTE: Syntax files required to be installed separately for Cuda-C++ and OpenCL.

Donation

If you find my work useful, please consider buying me a cup of coffee, all donations are much appreciated :)

Installation

With the Package Control plugin

The easiest way to install SublimeAStyleFormatter is through Package Control.

Once you have Package Control installed, restart Sublime Text.

  1. Bring up the Command Palette (Ctrl+Shift+P on Windows and Linux. ++P on OS X).
  2. Type “Install” and select “Package Control: Install Package”.
  3. Select “SublimeAStyleFormatter” from list.

The advantage of using Package Control is that it will keep SublimeAStyleFormatter up to date.

Manual Install

Without Git:

Download the latest source code, and extract it to the Packages directory.

With Git:

Type the following command in your Sublime Text 2 or Sublime Text 3 Packages directory:

git clone git://github.com/timonwong/SublimeAStyleFormatter.git

The “Packages” directory is located at:

Sublime Text 2

  • Windows: %APPDATA%\Sublime Text 2\Packages
  • Linux: ~/.config/sublime-text-2/Packages/
  • OS X: ~/Library/Application Support/Sublime Text 2/Packages/

Sublime Text 3

  • Windows: %APPDATA%\Sublime Text 3\Packages
  • Linux: ~/.config/sublime-text-3/Packages/
  • OS X: ~/Library/Application Support/Sublime Text 3/Packages/

Usage

Key Bindings

The default key bindings for this plugin:

Windows, Linux:

  • Ctrl+Alt+F: Format current file.
  • Ctrl+K, Ctrl+F: Format current selection.

OSX:

  • Ctrl+Alt+F: Format current file.
  • +K, +F: Format current selection.

Command Palette

Open the command palette, it appears as SublimeAStyleFormatter: Format Current File and SublimeAStyleFormatter Format Current Selection.

Settings

Per-project Settings

Before starting, you may want to have a look at SublimeAStyleFormatter.sublime-settings.

To edit your project setting, select Project/Edit Project from main menu. A project setting contains per-project settings for SublimeAStyleFormatter should look like this:

{
    "settings":
    {
        "AStyleFormatter":
        {
        }
    }
}

For example, if you don't want to inherit the default settings, instead, use your own astylerc file for C and C++ individually, then your project setting might look like this:

{
    // project folders, etc
    // ...
    // project settings
    "settings":
    {
        "AStyleFormatter":
        {
            "options_default":
            {
                // Use 2 spaces for indentation
                "indent": "spaces",
                "indent-spaces": 2
            },
            "options_c":
            {
                "use_only_additional_options": true,
                "additional_options_file": "/path/to/your/astylerc/for/c"
            },
            "options_c++":
            {
                "use_only_additional_options": true,
                "additional_options_file": "/path/to/your/astylerc/for/c++"
            }
        }
    }
}

What's New

CHANGELOG.md

License

This plugin is using MIT License:

Copyright (c) 2012-2015 Timon Wong

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Credits

Artistic Style - A Free, Fast and Small Automatic Formatter for C, C++, C#, and Java Source Code.

Licensed under GNU Lesser General Public License version 3.0

Donors

DONORS.md