Code Formatter plugin for ST2/ST3
CodeFormatter is a Sublime Text 2/3 plugin that supports format (beautify) source code.
CodeFormatter has support for the following languages:
No sponsors yet.. :(
With the Package Control plugin: The easiest way to install CodeFormatter is through Package Control, which can be found at this site: http://wbond.net/sublime_packages/package_control
Once you install Package Control, restart Sublime Text and bring up the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows). Select "Package Control: Install Package", wait while Package Control fetches the latest package list, then select CodeFormatter when the list appears. The advantage of using this method is that Package Control will automatically keep CodeFormatter up to date with the latest version.
Without Git: Download the latest source from GitHub and copy the CodeFormatter folder to your Sublime Text "Packages" directory.
With Git: Clone the repository in your Sublime Text "Packages" directory:
git clone https://github.com/akalongman/sublimetext-codeformatter.git CodeFormatterThe "Packages" directory is located at:
OS X:
ST2: ~/Library/Application Support/Sublime Text 2/Packages/
ST3: ~/Library/Application Support/Sublime Text 3/Packages/
Linux:
ST2: ~/.config/sublime-text-2/Packages/
ST3: ~/.config/sublime-text-3/Packages/
Windows:
ST2: %APPDATA%/Sublime Text 2/Packages/
ST3: %APPDATA%/Sublime Text 3/Packages/To change the default configurations you have to update the CodeFormatter - User Preferences file. You can find this file in the Sublime Text menu bar under: Sublime Text > Package Settings > CodeFormatter > Settings - User.
Make sure that you wrap all the configurations into a single root object.
{
"codeformatter_php_options": {...},
"codeformatter_js_options": {...},
..
}Following are notes specific to individual formatters that you should be aware of:
PHP - Used phpF by @subins2000
Getting and installing PHP - http://www.php.net/manual/en/install.general.php
You must install 5.6 or above (https://github.com/subins2000/phpF#requirements)
On Linux/OSx after installation of package, you must set chmod +x to file fmt.phar in folder %PACKAGESDIR%/CodeFormatter/codeformatter/lib/phpbeautifier
You can list all available transformations from Command Palette: CodeFormatter: Show PHP Transformations Examples of many transformations can be found here: PHP Transformation Examples
Language specific options:
…Javascript/JSON - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis
Language specific options:
…HTML - used custom python port, please use it with caution, feature in early beta
Language specific options:
…CSS - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis and Style Css by Harutyun Amirjanyan
Language specific options:
…SCSS - Simply modified the CSS formatter module as per the response from scss-lint (Gives way to modify further)
Language specific options:
…Python - used [PythonTidy] (https://pypi.python.org/pypi/PythonTidy/) by Chuck Rhode
Language specific options:
…Go - used gofmt
Currently no options are supported:
"codeformatter_go_options":
{
"syntaxes": "go",
"format_on_save": false // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : "^((?!.min.|vendor).)*$"
}Visual Basic/VBScript - used custom approach using the HTML beautifier as a guide
Language specific options:
…Language specific options:
…Tools -> Command Palette (Cmd+Shift+P or Ctrl+Shift+P) and type Format Code.
You can set up your own key combo for this, by going to Preferences -> Key Bindings - User, and adding a command in that huge array: { "keys": ["ctrl+alt+f"], "command": "code_formatter" },. Default keybinding is ctrl+alt+f. You can use any other key you want, thought most of them are already taken.
Add other languages support:
Add tests
If you like living on the edge, please report any bugs you find on the CodeFormatter issues page.
Pull requests are welcome. See CONTRIBUTING.md for information.
Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.
No open issues yet, or sync has not completed.