/sublime-format

Universal code formatter for Sublime Text 3

Primary LanguagePythonMIT LicenseMIT

Format

Because you have better things to worry about than formatting your code.

Contents

Supported Languages

Prerequisites

As this plugin merely acts as a proxy, each formatter will require it's own tool and options for code formatting.

Clang (clang-format)

Supports the C family of languages (C, C++, Objective-C, Objective-C++).

Download clang-format via you package manager or from the LLVM website.

npm install -g elm-format

Go (gofmt)

Installed with Go by default. Download go via your package manager or from the website.

Haskell (hindent)

stack install hindent

JavaScript (prettier)

npm install -g prettier

JSON (json)

Uses the JSON encoder and decoder from the Python standard library.

Python (yapf)

pip install yapf

Rust (rustfmt)

cargo install rustfmt

Swift (swiftformat)

brew install swiftformat

Terraform (terraform fmt)

Visit the website and follow the instructions to download and install.

Installation

Package Control (coming soon...)

  1. Install Package Control
  2. Run Package Control: Install Package in the Command Palette (Ctrl+Shift+P)
  3. Install Format

Manual (via Package Control)

  1. Install Package Control
  2. Run Package Control: Add Repository in the Command Palette
  3. Add the repository: https://github.com/Rypac/sublime-format.git
  4. Run Package Control: Install Package in the Command Palette
  5. Install sublime-format

Manual

  1. Navigate to the Sublime Text package directory

  2. Clone the repository

     git clone https://github.com/Rypac/sublime-format.git Format
    

Commands

  • Format: Format Selection
    • Format the current selection
  • Format: Format File
    • Format the current file
  • Format: Toggle Format on Save
    • Toggle formatting on save for all supported source file types
  • Format: Enable Format on Save...
    • Select source file types to enable automatic formatting on save
  • Format: Disable Format on Save...
    • Select source file types to disable automatic formatting on save

Keybindings

  • Format: Format Selection
    • OSX: (Cmd+K, Cmd+S)
    • Windows/Linux: (Ctrl+K, Ctrl+S)
  • Format: Format File
    • OSX: (Cmd+K, Cmd+F)
    • Windows/Linux: (Ctrl+K, Ctrl+F)