{"id":13448346,"url":"https://github.com/akalongman/sublimetext-codeformatter","last_synced_at":"2025-05-16T10:08:54.803Z","repository":{"id":7456379,"uuid":"8800855","full_name":"akalongman/sublimetext-codeformatter","owner":"akalongman","description":"Code Formatter plugin for ST2/ST3","archived":false,"fork":false,"pushed_at":"2024-05-15T14:32:26.000Z","size":2092,"stargazers_count":774,"open_issues_count":148,"forks_count":130,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-05-13T20:45:32.954Z","etag":null,"topics":["codeformatter","jsbeautifier","package","phpfmt","scss","sublime-text"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akalongman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-03-15T14:19:05.000Z","updated_at":"2025-03-05T06:38:05.000Z","dependencies_parsed_at":"2025-02-09T14:11:09.670Z","dependency_job_id":"7fede61e-8b15-4a96-8b9c-75909fd68311","html_url":"https://github.com/akalongman/sublimetext-codeformatter","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Fsublimetext-codeformatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Fsublimetext-codeformatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Fsublimetext-codeformatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Fsublimetext-codeformatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akalongman","download_url":"https://codeload.github.com/akalongman/sublimetext-codeformatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509477,"owners_count":22082892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeformatter","jsbeautifier","package","phpfmt","scss","sublime-text"],"created_at":"2024-07-31T05:01:42.770Z","updated_at":"2025-05-16T10:08:49.796Z","avatar_url":"https://github.com/akalongman.png","language":"Python","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_xclick\u0026business=akalongman@gmail.com\u0026item_name=Donation%20to%20Sublime%20Text%20-%20CodeFormatter\u0026item_number=1\u0026no_shipping=1"],"categories":["Python"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/akalongman/sublimetext-codeformatter.svg?branch=master)](https://travis-ci.org/akalongman/sublimetext-codeformatter)\n\nCodeFormatter\n=============\n\n\nCodeFormatter is a Sublime Text 2/3 plugin that supports format (beautify) source code.\n\n\nCodeFormatter has support for the following languages:\n\n* PHP - By [phpF](https://github.com/subins2000/phpF)\n* JavaScript/JSON - By JSBeautifier\n* HTML - By [Custom fork of BeautifulSoup](https://github.com/akalongman/python-beautifulsoup)\n* CSS,LESS,SASS - By JSBeautifier\n* Python - By PythonTidy (only ST2)\n* Go - By [gofmt](https://golang.org/cmd/gofmt/)\n* Visual Basic/VBScript\n* Coldfusion/Railo/Lucee\n\n\nSponsors\n-----\nNo sponsors yet.. :(\n\nIf you like the software, don't forget to donate to further development of it!\n\n[![PayPal donate button](https://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_pp_142x27.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_xclick\u0026business=akalongman@gmail.com\u0026item_name=Donation%20to%20Sublime%20Text%20-%20CodeFormatter\u0026item_number=1\u0026no_shipping=1 \"Donate to this project using Paypal\")\n\n\nInstalling\n----------\n**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\n\nOnce 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.\n\n**Without Git:** Download the latest source from [GitHub](https://github.com/akalongman/sublimetext-codeformatter) and copy the CodeFormatter folder to your Sublime Text \"Packages\" directory.\n\n**With Git:** Clone the repository in your Sublime Text \"Packages\" directory:\n\n    git clone https://github.com/akalongman/sublimetext-codeformatter.git CodeFormatter\n\n\nThe \"Packages\" directory is located at:\n\n* OS X:\n\n        ST2: ~/Library/Application Support/Sublime Text 2/Packages/\n        ST3: ~/Library/Application Support/Sublime Text 3/Packages/\n\n* Linux:\n\n        ST2: ~/.config/sublime-text-2/Packages/\n        ST3: ~/.config/sublime-text-3/Packages/\n\n* Windows:\n\n        ST2: %APPDATA%/Sublime Text 2/Packages/\n        ST3: %APPDATA%/Sublime Text 3/Packages/\n\n## Configuration\n\nTo 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 \u003e Package Settings \u003e CodeFormatter \u003e Settings - User`. \n\nMake sure that you wrap all the configurations into a single root object.\n\n```js\n{\n   \"codeformatter_php_options\": {...},\n   \"codeformatter_js_options\": {...},\n   ..\n}\n```\n\n## Formatter-specific notes\nFollowing are notes specific to individual formatters that you should be aware of:\n### PHP\nPHP - Used [phpF](https://github.com/subins2000/phpF) by [@subins2000](https://github.com/subins2000)\n\nGetting and installing PHP - http://www.php.net/manual/en/install.general.php\n\nYou must install 5.6 or above (https://github.com/subins2000/phpF#requirements)\n\nOn Linux/OSx after installation of package, you must set chmod +x to file fmt.phar in folder %PACKAGESDIR%/CodeFormatter/codeformatter/lib/phpbeautifier\n\nYou can list all available transformations from Command Palette: CodeFormatter: Show PHP Transformations\nExamples of many transformations can be found here: [PHP Transformation Examples](https://github.com/akalongman/sublimetext-codeformatter/blob/master/PHP-Transformations.md)\n\nLanguage specific options:\n```js\n   \"codeformatter_php_options\":\n    {\n        \"syntaxes\": \"php\", // Syntax names which must process PHP formatter\n        \"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\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"psr1\": false, // Activate PSR1 style\n        \"psr1_naming\": false, // Activate PSR1 style - Section 3 and 4.3 - Class and method names case\n        \"psr2\": true, // Activate PSR2 style\n        \"indent_with_space\": 4, // Use spaces instead of tabs for indentation\n        \"enable_auto_align\": true, // Enable auto align of = and =\u003e\n        \"visibility_order\": true, // Fixes visibility order for method in classes - PSR-2 4.2\n        \"smart_linebreak_after_curly\": true, // Convert multistatement blocks into multiline blocks\n\n        // Enable specific transformations. Example: [\"ConvertOpenTagWithEcho\", \"PrettyPrintDocBlocks\"]\n        // You can list all available transformations from command palette: CodeFormatter: Show PHP Transformations\n        // You can also see examples of many transformations at https://github.com/akalongman/sublimetext-codeformatter/blob/master/PHP-Transformations.md\n        \"passes\": [],\n\n        // Disable specific transformations\n        \"excludes\": []\n    }\n```\n\n\n\n### Javascript/JSON\nJavascript/JSON - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis\n\nLanguage specific options:\n```js\n    \"codeformatter_js_options\":\n    {\n        \"syntaxes\": \"javascript,json\", // Syntax names which must process JS formatter\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_size\": 4, // indentation size\n        \"indent_char\": \" \", // Indent character\n        \"indent_with_tabs\": false, // Indent with one tab (overrides indent_size and indent_char options)\n        \"eol\": \"\\n\", // EOL symbol\n        \"preserve_newlines\": false, // whether existing line breaks should be preserved,\n        \"max_preserve_newlines\": 10, // maximum number of line breaks to be preserved in one chunk\n        \"space_in_paren\": false, // Add padding spaces within paren, ie. f( a, b )\n        \"space_in_empty_paren\": false, // Add padding spaces within paren if parent empty, ie. f(  )\n        \"e4x\": false, // Pass E4X xml literals through untouched\n        \"jslint_happy\": false, // if true, then jslint-stricter mode is enforced. Example function () vs function()\n        \"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.\n        \"keep_array_indentation\": false, // keep array indentation.\n        \"keep_function_indentation\": false, // keep function indentation.\n        \"eval_code\": false, // eval code\n        \"unescape_strings\": false, // Decode printable characters encoded in xNN notation\n        \"wrap_line_length\": 0, // Wrap lines at next opportunity after N characters\n        \"break_chained_methods\": false, // Break chained method calls across subsequent lines\n        \"end_with_newline\": false, // Add new line at end of file\n        \"comma_first\": false // Add comma first\n    }\n```\n\n### HTML\nHTML - used custom python port, please use it with caution, feature in early beta\n\nLanguage specific options:\n```js\n    \"codeformatter_html_options\":\n    {\n        \"syntaxes\": \"html,asp,xml\", // Syntax names which must process HTML formatter\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_size\": 4, // indentation size\n        \"indent_char\": \" \", // Indentation character\n        \"indent_with_tabs\": false, // Indent with one tab (overrides indent_size and indent_char options)\n        \"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\n        \"expand_javascript\": false, // Expand JavaScript inside of \u003cscript\u003e tags (also affects CSS purely by coincidence)\n        \"expand_tags\": false, // Expand tag attributes onto new lines\n        \"minimum_attribute_count\": 2, // Minimum number of attributes needed before tag attributes are expanded to new lines\n        \"first_attribute_on_new_line\": false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)\n        \"reduce_empty_tags\": false, // Put closing tags on same line as opening tag if there is no content between them\n        \"reduce_whole_word_tags\": false, // Put closing tags on same line as opening tag if there is whole word between them\n        \"custom_singletons\": \"\" // Custom singleton tags for various template languages outside of the HTML5 spec\n    }\n```\n\n### CSS\nCSS - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis and Style Css by Harutyun Amirjanyan\n\nLanguage specific options:\n```js\n    \"codeformatter_css_options\":\n    {\n        \"syntaxes\": \"css,less\", // Syntax names which must process CSS formatter\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_size\": 4, // Indentation size\n        \"indent_char\": \" \", // Indentation character\n        \"indent_with_tabs\": false, // Indent with one tab (overrides indent_size and indent_char options)\n        \"selector_separator_newline\": false, // Add new lines after selector separators\n        \"end_with_newline\": false, // Add new line of end in file\n        \"newline_between_rules\": false, // Add new line between rules\n        \"eol\": \"\\n\" // EOL symbol\n    }\n```\n### SCSS\nSCSS - Simply modified the CSS formatter module as per the response from scss-lint (Gives way to modify further)\n\nLanguage specific options:\n```js\n    \"codeformatter_scss_options\":\n    {\n        \"syntaxes\": \"scss\", // Indentation size\n        \"indent_size\": 2, // Indentation size\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_char\": \" \", // Indentation character\n        \"indent_with_tabs\": false, // Indent with one tab (overrides indent_size and indent_char options)\n        \"selector_separator_newline\": true, // Add new lines after selector separators\n        \"newline_between_rules\": true, // Add new line between rules\n        \"end_with_newline\": true // Add new line of end in file\n    }\n```\n\n### Python\nPython - used [PythonTidy] (https://pypi.python.org/pypi/PythonTidy/) by Chuck Rhode\n\nLanguage specific options:\n```js\n    \"codeformatter_python_options\":\n    {\n        \"syntaxes\": \"python\", // Syntax names which must process Python formatter\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_size\": 1, // indentation size\n        \"indent_with_tabs\": true, // Indent with tabs or spaces\n        \"max_char\": 80, // Width of output lines in characters.\n        \"assignment\": \" = \", // This is how the assignment operator is to appear.\n        \"function_param_assignment\": \"=\", // This is how function-parameter assignment should appear.\n        \"function_param_sep\": \", \", // This is how function parameters are separated.\n        \"list_sep\": \", \", // This is how list items are separated.\n        \"subscript_sep\": \"=\", // This is how subscripts are separated.\n        \"dict_colon\": \": \", // This separates dictionary keys from values.\n        \"slice_colon\": \":\", // this separates the start:end indices of slices.\n        \"comment_prefix\": \"# \", // This is the sentinel that marks the beginning of a commentary string.\n        \"shebang\": \"#!/usr/bin/env python\", // Hashbang, a line-one comment naming the Python interpreter to Unix shells.\n        \"boilerplate\": \"\", // Standard code block (if any). This is inserted after the module doc string on output.\n        \"blank_line\": \"\", // This is how a blank line is to appear (up to the newline character).\n        \"keep_blank_lines\": true, // If true, preserve one blank where blank(s) are encountered.\n        \"add_blank_lines_around_comments\": true, // If true, set off comment blocks with blanks.\n        \"add_blank_line_after_doc_string\": true, // If true, add blank line after doc strings.\n        \"max_seps_func_def\": 3, // Split lines containing longer function definitions.\n        \"max_seps_func_ref\": 5, // Split lines containing longer function calls.\n        \"max_seps_series\": 5, // Split lines containing longer lists or tuples.\n        \"max_seps_dict\": 3, // Split lines containing longer dictionary definitions.\n        \"max_lines_before_split_lit\": 2, // Split string literals containing more newline characters.\n        \"left_margin\": \"\", // This is how the left margin is to appear.\n        \"normalize_doc_strings\": false, // If true, normalize white space in doc strings.\n        \"leftjust_doc_strings\": false, // If true, left justify doc strings.\n        \"wrap_doc_strings\": false, // If true, wrap doc strings to max_char.\n        \"leftjust_comments\": false, // If true, left justify comments.\n        \"wrap_comments\": false, // If true, wrap comments to max_char.\n        \"double_quoted_strings\": false, // If true, use quotes instead of apostrophes for string literals.\n        \"single_quoted_strings\": false, // If true, use apostrophes instead of quotes for string literals.\n        \"can_split_strings\": false, // If true, longer strings are split at the max_char.\n        \"doc_tab_replacement\": \"....\", // This literal replaces tab characters in doc strings and comments.\n\n        // Optionally preserve unassigned constants so that code to be tidied\n        // may contain blocks of commented-out lines that have been no-op'ed\n        // with leading and trailing triple quotes.  Python scripts may declare\n        // constants without assigning them to a variables, but CodeFormatter\n        // considers this wasteful and normally elides them.\n        \"keep_unassigned_constants\": false,\n\n        // Optionally omit parentheses around tuples, which are superfluous\n        // after all.  Normal CodeFormatter behavior will be still to include them\n        // as a sort of tuple display analogous to list displays, dict\n        // displays, and yet-to-come set displays.\n        \"parenthesize_tuple_display\": true,\n\n        // When CodeFormatter splits longer lines because max_seps\n        // are exceeded, the statement normally is closed before the margin is\n        // restored.  The closing bracket, brace, or parenthesis is placed at the\n        // current indent level.  This looks ugly to \"C\" programmers.  When\n        // java_style_list_dedent is True, the closing bracket, brace, or\n        // parenthesis is brought back left to the indent level of the enclosing\n        // statement.\n        \"java_style_list_dedent\": false\n    }\n```\n\n### Go\nGo - used [gofmt](https://golang.org/src/cmd/gofmt/gofmt.go)\n\nCurrently no options are supported:\n```js\n    \"codeformatter_go_options\":\n    {\n        \"syntaxes\": \"go\",\n        \"format_on_save\": false // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n    }\n```\n\n### Visual Basic/VBScript\nVisual Basic/VBScript - used custom approach using the HTML beautifier as a guide\n\nLanguage specific options:\n```js\n    \"codeformatter_vbscript_options\":\n    {\n        \"syntaxes\": \"vbscript\", // Syntax names which must process VBScript formatter\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_size\": 1, // indentation size\n        \"indent_char\": \"\\t\", // Indentation character\n        \"indent_with_tabs\": true, // Indent with one tab (overrides indent_size and indent_char options)\n        \"preserve_newlines\": true, // Preserve existing line-breaks\n        \"max_preserve_newlines\": 10, // Maximum number of line-breaks to be preserved in one chunk\n        \"opening_tags\": \"^(Function .*|Sub .*|If .* Then|For .*|Do While .*|Select Case.*)\", // List of keywords which open a new block\n        \"middle_tags\": \"^(Else|ElseIf .* Then|Case .*)$\", // List of keywords which divide a block, but neither open or close the block\n        \"closing_tags\": \"(End Function|End Sub|End If|Next|Loop|End Select)$\" // List of keywords which close an open block\n    }\n```\n\n### Coldfusion Markup Language\n\nLanguage specific options:\n```js\n    \"codeformatter_coldfusion_options\":\n    {\n        \"syntaxes\": \"coldfusion,cfm,cfml\", // Syntax names which must process Coldfusion Markup Language formatter\n        \"format_on_save\": false, // Format on save. Either a boolean (true/false) or a string regexp tested on filename. Example : \"^((?!.min.|vendor).)*$\"\n        \"indent_size\": 2, // indentation size\n        \"indent_char\": \" \", // Indentation character\n        \"indent_with_tabs\": false, // Indent with one tab (overrides indent_size and indent_char options)\n        \"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\n        \"expand_javascript\": false, // Expand JavaScript inside of \u003cscript\u003e tags (also affects CSS purely by coincidence)\n        \"expand_tags\": false, // Expand tag attributes onto new lines\n        \"minimum_attribute_count\": 2, // Minimum number of attributes needed before tag attributes are expanded to new lines\n        \"first_attribute_on_new_line\": false // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)\n        \"reduce_empty_tags\": false, // Put closing tags on same line as opening tag if there is no content between them\n        \"reduce_whole_word_tags\": false, // Put closing tags on same line as opening tag if there is whole word between them\n        \"custom_singletons\": \"\" // Custom singleton tags for various template languages outside of the HTML5 spec\n    }\n```\n\nUsage\n-----\nTools -\u003e Command Palette (`Cmd+Shift+P` or `Ctrl+Shift+P`) and type `Format Code`.\n\nYou can set up your own key combo for this, by going to Preferences -\u003e 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.\n\n## TODO\n\nAdd other languages support:\n* Python (for ST3)\n* Perl\n* Ruby\n\nAdd tests\n\n## Troubleshooting\n\nIf you like living on the edge, please report any bugs you find on the [CodeFormatter issues](https://github.com/akalongman/sublimetext-codeformatter/issues) page.\n\n## Contributing\n\nPull requests are welcome.\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information.\n\n## License\n\nPlease see the [LICENSE](LICENSE.md) included in this repository for a full copy of the MIT license,\nwhich this project is licensed under.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakalongman%2Fsublimetext-codeformatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakalongman%2Fsublimetext-codeformatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakalongman%2Fsublimetext-codeformatter/lists"}