CodeFormatter
Code Formatter plugin for ST2/ST3
Details
Installs
- Total 326K
- Win 208K
- Mac 72K
- Linux 45K
Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | Nov 6 | Nov 5 | Nov 4 | Nov 3 | Nov 2 | Nov 1 | Oct 31 | Oct 30 | Oct 29 | Oct 28 | Oct 27 | Oct 26 | Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 10 | 2 | 7 | 8 | 11 | 13 | 7 | 0 | 0 | 15 | 5 | 9 | 12 | 16 | 20 | 13 | 15 | 13 | 7 | 12 | 12 | 11 | 15 | 17 | 11 | 4 | 12 | 16 | 25 | 12 | 12 | 13 | 5 | 5 | 14 | 18 | 9 | 23 | 11 | 13 | 9 | 10 | 21 | 14 | 14 | 15 |
Mac | 2 | 1 | 3 | 6 | 2 | 3 | 4 | 0 | 0 | 4 | 5 | 2 | 6 | 9 | 3 | 4 | 5 | 5 | 4 | 3 | 2 | 4 | 2 | 11 | 1 | 3 | 2 | 4 | 7 | 10 | 2 | 4 | 4 | 4 | 4 | 7 | 3 | 9 | 4 | 2 | 3 | 9 | 6 | 4 | 6 | 5 |
Linux | 0 | 1 | 2 | 1 | 2 | 2 | 4 | 0 | 0 | 4 | 3 | 2 | 3 | 4 | 0 | 0 | 1 | 1 | 2 | 1 | 0 | 3 | 9 | 1 | 1 | 1 | 3 | 5 | 1 | 3 | 6 | 3 | 0 | 3 | 1 | 3 | 4 | 1 | 2 | 4 | 1 | 6 | 0 | 3 | 4 | 3 |
Readme
- Source
- raw.githubusercontent.com
CodeFormatter
CodeFormatter is a Sublime Text 2/3 plugin that supports format (beautify) source code.
CodeFormatter has support for the following languages:
- PHP - By phpF
- JavaScript/JSON - By JSBeautifier
- HTML - By Custom fork of BeautifulSoup
- CSS,LESS,SASS - By JSBeautifier
- Python - By PythonTidy (only ST2)
- Go - By gofmt
- Visual Basic/VBScript
- Coldfusion/Railo/Lucee
Sponsors
No sponsors yet.. :(
If you like the software, don't forget to donate to further development of it!
Installing
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 CodeFormatter
The “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/
Configuration
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": {...},
..
}
Formatter-specific notes
Following are notes specific to individual formatters that you should be aware of:
PHP
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: “js "codeformatter_php_options”: { “syntaxes”: “php”, // Syntax names which must process PHP formatter “php_path”: “”, // Path for PHP executable, e.g. “/usr/lib/php” or “C:/Program Files/PHP/php.exe”. If empty, uses command “php” from system environments “format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “(?!.min.|vendor.)*$” “psr1”: false, // Activate PSR1 style “psr1_naming”: false, // Activate PSR1 style - Section 3 and 4.3 - Class and method names case “psr2”: true, // Activate PSR2 style “indent_with_space”: 4, // Use spaces instead of tabs for indentation “enable_auto_align”: true, // Enable auto align of = and => “visibility_order”: true, // Fixes visibility order for method in classes - PSR-2 4.2 “smart_linebreak_after_curly”: true, // Convert multistatement blocks into multiline blocks
// Enable specific transformations. Example: ["ConvertOpenTagWithEcho", "PrettyPrintDocBlocks"]
// You can list all available transformations from command palette: CodeFormatter: Show PHP Transformations
// You can also see examples of many transformations at https://github.com/akalongman/sublimetext-codeformatter/blob/master/PHP-Transformations.md
"passes": [],
// Disable specific transformations
"excludes": []
}
### Javascript/JSON
Javascript/JSON - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis
Language specific options:
```js
"codeformatter_js_options":
{
"syntaxes": "javascript,json", // Syntax names which must process JS formatter
"format_on_save": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : "^((?!.min.|vendor).)*$"
"indent_size": 4, // indentation size
"indent_char": " ", // Indent character
"indent_with_tabs": false, // Indent with one tab (overrides indent_size and indent_char options)
"eol": "\n", // EOL symbol
"preserve_newlines": false, // whether existing line breaks should be preserved,
"max_preserve_newlines": 10, // maximum number of line breaks to be preserved in one chunk
"space_in_paren": false, // Add padding spaces within paren, ie. f( a, b )
"space_in_empty_paren": false, // Add padding spaces within paren if parent empty, ie. f( )
"e4x": false, // Pass E4X xml literals through untouched
"jslint_happy": false, // if true, then jslint-stricter mode is enforced. Example function () vs function()
"brace_style": "collapse", // "collapse" | "expand" | "end-expand". put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line.
"keep_array_indentation": false, // keep array indentation.
"keep_function_indentation": false, // keep function indentation.
"eval_code": false, // eval code
"unescape_strings": false, // Decode printable characters encoded in xNN notation
"wrap_line_length": 0, // Wrap lines at next opportunity after N characters
"break_chained_methods": false, // Break chained method calls across subsequent lines
"end_with_newline": false, // Add new line at end of file
"comma_first": false // Add comma first
}
HTML
HTML - used custom python port, please use it with caution, feature in early beta
Language specific options: “js "codeformatter_html_options”: { “syntaxes”: “html,asp,xml”, // Syntax names which must process HTML formatter “format_on_save”: false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : “(?!.min.|vendor.)*$” “indent_size”: 4, // indentation size “indent_char”: “ ”, // Indentation character “indent_with_tabs”: false, // Indent with one tab (overrides indent_size and indent_char options) “exception_on_tag_mismatch”: false, // If the last closing tag is not at the same indentation level as the first opening tag, there's probably a tag mismatch in the file “expand_javascript”: false, // Expand JavaScript inside of