Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
SublimeAStyleFormatter is a code formatter/beautifier for Sublime Text 2 & 3. It provides ability to format C/C++/C#/Java files.
Python JavaScript Shell

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
AStyle.dll
AStyleFormat.py
AStyleLib.py
AStyleOptions.py
AStyle_x64.dll
Default (Linux).sublime-keymap
Default (OSX).sublime-keymap
Default (Windows).sublime-keymap
Default.sublime-commands
Main.sublime-menu
README.creole
Settings.py
SublimeAStyleFormatter.sublime-settings
libastyle.dylib
package.json

README.creole

Sublime Text 2 AStyle Formatter Plugin

Description

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

Prerequisites (Linux Only)

  1. ctypes can't be imported in Linux right now in the Linux versions of Sublime Text 2, However, a workaround is provided by mnus.
  2. The Linux libastyle.so is not provided right now:
    1. Download and compile astyle: cd astyle/build/gcc; make shared
    2. Copy libastyle.so to SublimeAStyleFormatter directory: cp ../../bin/libastyle.so "~/.Sublime Text 2/Packages/SublimeAStyleFormatter"

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 2.

  1. Bring up the Command Pattle (Ctrl+Shift+P on Windows and Linux. Command+Shift+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 to the Packages directory.

With Git: Type the following command in your Sublime Text 2 Packages directory:

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

The "Packages" directory is located at:

Windows %APPDATA%\Sublime Text 2\Packages\
Linux ~/.Sublime Text 2/Packages/
OS X ~/Library/Application Support/Sublime Text 2/Packages/

Usage

Key Bindings

The default key bindings for this plugin:

Windows, Linux:

ctrl+alt+fFormat current file

OSX:

super+alt+fFormat current file

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:

{
    "settings": 
    {
        "AStyleFormatter": 
        {
            "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

v1.2 (4/19/2012)

  • Add support for per-project settings.
  • Fix a bug that "additional_options" is invalid when "use_only_additional_options " is not "true".
  • Fix a bug which will throw python 'KeyError' exception while options in "options_default" are lesser than expected.

v1.1 (2/5/2012)

  • Add support for OS X.
  • More comprehensive options.

License

This plugin is using MIT License

Copyright (c) 2012 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

Something went wrong with that request. Please try again.