Skip to content
SublimeAStyleFormatter is a code formatter/beautifier for Sublime Text 2 & 3. It provides ability to format C/C++/C#/Java files.
Python JavaScript Shell
Latest commit 0ac8284 Apr 4, 2015 @timonwong Add messages for v3.1.2
[skip ci]
Failed to load latest commit information.
AStyleFormatterLib Fix `AttributeError` for RangeError class Apr 4, 2015
messages Add messages for v3.1.2 Apr 4, 2015
pyastyle Update Windows binaries for pyastyle, thanks to appveyor Feb 20, 2015
src Update bundling pyastyle source submodule Feb 26, 2015
tests Fix unit tests, load defaults before run Feb 28, 2015
.gitignore Fix build script Feb 19, 2015
.gitmodules Add build script for pyastyle Nov 5, 2012
.no-sublime-package No longer a zip through Package Control, fix #15 Mar 24, 2013
.travis.yml Add travis file for testing Feb 26, 2015
AStyleFormat.py Strip invalid options before run. #39 Mar 2, 2015
AStyleFormatter.sublime-commands Give a proper name for sublime-commands file Jul 2, 2013
CHANGELOG.md Add messages for v3.1.2 Apr 4, 2015
Context.sublime-menu set context menu id Dec 26, 2012
DONORS.md Thanks for your support πŸ˜„ Feb 18, 2015
Default (Linux).sublime-keymap add sidebar/context commands Dec 24, 2012
Default (OSX).sublime-keymap add sidebar/context commands Dec 24, 2012
Default (Windows).sublime-keymap add sidebar/context commands Dec 24, 2012
LICENSE Upgrade pyastyle module and build script, for astyle v2.05.1 Feb 18, 2015
Main.sublime-menu Fix wrong user keymap setting file location, fixes #27 Dec 6, 2013
README.md Update build badges to README file Feb 26, 2015
Side Bar.sublime-menu Fix license header from borrowed GoSublime source Dec 31, 2012
SublimeAStyleFormatter.sublime-settings Remove 'conver-tabs' options, use ST instead Feb 26, 2015
appveyor.yml Add appveyor file for testing Feb 26, 2015
dump_default_options Besides refactor, use tab settings from Sublime Text itself by default Feb 19, 2015
messages.json Add messages for v3.1.1 Feb 28, 2015
options_default.json Remove 'conver-tabs' options, use ST instead Feb 26, 2015
package.json Handles Objective-C and Objective-C++ files Aug 10, 2013
unittesting.json Add test for `astyleformat' command Feb 26, 2015

README.md

Sublime Text 2 & 3 AStyle Formatter Plugin

Travis-CI Build Status 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 :)

Donate via PayPal

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

Something went wrong with that request. Please try again.