Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sublimetext-codeformatter

> 前端框架
Open source

Code Formatter plugin for ST2/ST3

771 stars0 likes0 views
WebsiteGitHub

About

Code Formatter plugin for ST2/ST3

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:

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

javascript
{
   "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:

…

Javascript/JSON

Javascript/JSON - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis

Language specific options:

…

HTML

HTML - used custom python port, please use it with caution, feature in early beta

Language specific options:

…

CSS

CSS - used [JSBeautifier] (http://jsbeautifier.org/) by Einar Lielmanis and Style Css by Harutyun Amirjanyan

Language specific options:

…

SCSS

SCSS - Simply modified the CSS formatter module as per the response from scss-lint (Gives way to modify further)

Language specific options:

…

Python

Python - used [PythonTidy] (https://pypi.python.org/pypi/PythonTidy/) by Chuck Rhode

Language specific options:

…

Go

Go - used gofmt

Currently no options are supported:

javascript
    "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

Visual Basic/VBScript - used custom approach using the HTML beautifier as a guide

Language specific options:

…

Coldfusion Markup Language

Language specific options:

…

Usage

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.

TODO

Add other languages support:

  • Python (for ST3)
  • Perl
  • Ruby

Add tests

Troubleshooting

If you like living on the edge, please report any bugs you find on the CodeFormatter issues page.

Contributing

Pull requests are welcome. See CONTRIBUTING.md for information.

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythoncodeformatterjsbeautifierpackagephpfmt

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架