2016-07-02 16:28:01 -06:00
# :lipstick: [atom-beautify](https://github.com/Glavin001/atom-beautify)
2014-03-03 00:51:16 -07:00
2016-07-22 08:27:47 -06:00
| Mac OS < img src = "https://cloud.githubusercontent.com/assets/1885333/17059766/2530c9d8-4ffd-11e6-9529-3fa47dbff616.png" width = "50px" > | < img src = "https://cloud.githubusercontent.com/assets/1885333/17059750/11c4474e-4ffd-11e6-89e1-2486ca5b3234.png" width = "100px" > | < img src = "https://cloud.githubusercontent.com/assets/1885333/17059763/206a7d4a-4ffd-11e6-859e-7856902fb300.png" width = "100px" > |
| --- | --- | --- |
| [![Build Status ](https://travis-ci.org/Glavin001/atom-beautify.svg?branch=master )](https://travis-ci.org/Glavin001/atom-beautify) | [![Build Status ](https://travis-ci.org/Glavin001/atom-beautify.svg?branch=master )](https://travis-ci.org/Glavin001/atom-beautify) | [![Build status ](https://ci.appveyor.com/api/projects/status/himnq7tjxl2fdc8u?svg=true )](https://ci.appveyor.com/project/Glavin001/atom-beautify) |
2015-05-04 16:05:50 -06:00
[![Gitter chat ](https://img.shields.io/badge/gitter-Glavin001%2Fatom--beautify-1dce73.svg )](https://gitter.im/Glavin001/atom-beautify)
2015-06-04 11:59:35 -06:00
[![Paypal Donations ](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif )](https://www.paypal.com/cgi-bin/webscr?cmd=_donations& business=X2RK5DKN6YXPJ& lc=CA& item_name=Atom%2dBeautify& item_number=atom%2dbeautify& currency_code=CAD& bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted)
2015-07-13 07:52:10 -06:00
[![Throughput Graph ](https://graphs.waffle.io/Glavin001/atom-beautify/throughput.svg )](https://waffle.io/Glavin001/atom-beautify/metrics)
2014-08-08 11:38:28 -06:00
2016-07-02 16:28:01 -06:00
> Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom
| Before | After |
| --- | ---- |
| Original HTML | Beautified HTML |
| ![image ](https://cloud.githubusercontent.com/assets/1885333/16542727/db52adc6-408a-11e6-824e-04aed06bd2f7.png ) | ![image ](https://cloud.githubusercontent.com/assets/1885333/16542728/dcac3700-408a-11e6-8e35-9c8fc4432edc.png ) |
## Table of Contents
- [Installation ](#installation )
- [Language Support ](#language-support )
- [Usage ](#usage )
- [Selection of Code ](#selection-of-code )
- [Beautify On Save ](#beautify-on-save )
- [Keyboard Shortcut ](#keyboard-shortcut )
- [Custom Keyboard Shortcuts ](#custom-keyboard-shortcuts )
- [Configuration ](#configuration )
- [Simple ](#simple )
- [Nested ](#nested-recommended )
- [Troubleshooting ](#troubleshooting )
- [Contributing ](#contributing )
## Installation
2014-03-03 00:51:16 -07:00
2014-06-13 23:21:26 -06:00
Atom Package: https://atom.io/packages/atom-beautify
2014-08-08 11:38:28 -06:00
```bash
apm install atom-beautify
```
Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
2014-06-12 22:25:39 -06:00
## Language Support
2016-07-02 16:28:01 -06:00
See [all supported options in the documentation at `docs/options.md` ](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md ).
| Language | Grammars | File Extensions | Supported Beautifiers |
| --- | --- | --- | ---- |
| Apex | `Apex` |`.cls`, `.trigger` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| Arduino | `Arduino` |`.ino`, `.pde` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| C | `C` , `opencl` |`.h`, `.c` , `.cl` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default), [`clang-format` ](https://clang.llvm.org/docs/ClangFormat.html ) |
| Coldfusion | `html` |`.cfm`, `.cfml` , `.cfc` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| CoffeeScript | `CoffeeScript` |`.coffee` | [`Coffee Formatter` ](https://github.com/Glavin001/Coffee-Formatter ), [`coffee-fmt` ](https://github.com/sterpe/coffee-fmt ) (Default) |
| C++ | `C++` |`.h`, `.hh` , `.cc` , `.cpp` , `.cxx` , `.C` , `.c++` , `.hpp` , `.hxx` , `.h++` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default), [`clang-format` ](https://clang.llvm.org/docs/ClangFormat.html ) |
| Crystal | `Crystal` |`.cr` | [`Crystal` ](http://crystal-lang.org ) (Default) |
| C# | `C#` |`.cs` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| CSS | `CSS` |`.css` | [`CSScomb` ](https://github.com/csscomb/csscomb.js ), [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
| CSV | `CSV` |`.csv` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| D | `D` |`.d` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default), [`dfmt` ](https://github.com/Hackerpilot/dfmt ) |
| EJS | `JavaScript Template` , `HTML (Angular)` | | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Elm | `Elm` |`.elm` | [`elm-format` ](https://github.com/avh4/elm-format ) (Default) |
| ERB | `HTML (Ruby - ERB)` , `HTML (Rails)` |`.erb` | [`HTML Beautifier` ](https://github.com/threedaymonk/htmlbeautifier ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Erlang | `Erlang` |`.erl` | [`erl_tidy` ](http://erlang.org/doc/man/erl_tidy.html ) (Default) |
| Fortran | `Fortran - Modern` |`.f90` | [`Fortran Beautifier` ](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp ) (Default) |
| gherkin | `Gherkin` |`.feature` | [`Gherkin formatter` ](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee ) (Default) |
| Go | `Go` |`.go` | [`gofmt` ](https://golang.org/cmd/gofmt/ ) (Default) |
| Handlebars | `Handlebars` , `HTML (Handlebars)` |`.hbs`, `.handlebars` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
| Haskell | `Haskell` |`.hs` | [`stylish-haskell` ](https://github.com/jaspervdj/stylish-haskell ) (Default) |
| HTML | `HTML` |`.html` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
| Jade | `Jade` , `Pug` |`.jade`, `.pug` | [`Pug Beautify` ](https://github.com/vingorius/pug-beautify ) (Default) |
| Java | `Java` |`.java` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| JavaScript | `JavaScript` |`.js` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`JSCS Fixer` ](https://github.com/jscs-dev/node-jscs/ ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
| JSON | `JSON` |`.json` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
| JSX | `JSX` , `JavaScript (JSX)` |`.jsx`, `.js` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| LaTeX | `LaTeX` |`.tex` | [`Latex Beautify` ](https://github.com/cmhughes/latexindent.pl ) (Default) |
| LESS | `LESS` |`.less` | [`CSScomb` ](https://github.com/csscomb/csscomb.js ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Lua | `Lua` |`.lua` | [`Lua beautifier` ](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl ) (Default) |
| Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark` ](https://github.com/wooorm/remark ), [`Tidy Markdown` ](https://github.com/slang800/tidy-markdown ) (Default) |
| Marko | `Marko` |`.marko` | [`Marko Beautifier` ](https://github.com/marko-js/marko-prettyprint ) (Default) |
| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default) |
| Objective-C | `Objective-C` , `Objective-C++` |`.m`, `.mm` , `.h` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default), [`clang-format` ](https://clang.llvm.org/docs/ClangFormat.html ) |
| OCaml | `OCaml` |`.ml` | [`ocp-indent` ](https://www.typerex.org/ocp-indent.html ) (Default) |
| Pawn | `Pawn` | | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| Perl | `Perl` , `Perl 6` |`.pl` | [`Perltidy` ](http://perltidy.sourceforge.net/ ) (Default) |
| PHP | `PHP` |`.php`, `.module` , `.inc` | [`PHP-CS-Fixer` ](http://php.net/manual/en/install.php ) (Default), [`PHPCBF` ](http://php.net/manual/en/install.php ) |
| Puppet | `Puppet` |`.pp` | [`puppet-lint` ](http://puppet-lint.com/ ) (Default) |
| Python | `Python` |`.py` | [`autopep8` ](https://github.com/hhatto/autopep8 ) (Default), [`yapf` ](https://github.com/google/yapf ) |
| Riot.js | `Riot.js` , `HTML (Riot Tag)` |`.tag` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Ruby | `Ruby` , `Ruby on Rails` |`.rb` | [`Rubocop` ](https://github.com/bbatsov/rubocop ) (Default), [`Ruby Beautify` ](https://github.com/erniebrodeur/ruby-beautify ) |
| Rust | `Rust` |`.rs`, `.rlib` | [`rustfmt` ](https://github.com/nrc/rustfmt ) (Default) |
| Sass | `Sass` |`.sass` | [`CSScomb` ](https://github.com/csscomb/csscomb.js ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| SCSS | `SCSS` |`.scss` | [`CSScomb` ](https://github.com/csscomb/csscomb.js ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Spacebars | `Spacebars` | | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| SQL | `SQL (Rails)` , `SQL` |`.sql` | [`sqlformat` ](https://github.com/andialbrecht/sqlparse ) (Default) |
| SVG | `SVG` |`.svg` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Swig | `HTML (Swig)` , `SWIG` |`.swig` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| TSS | `TSS` |`.tss` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| Twig | `HTML (Twig)` |`.twig` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| TypeScript | `TypeScript` |`.ts` | [`TypeScript Formatter` ](https://github.com/vvakame/typescript-formatter ) (Default) |
| Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| Visualforce | `Visualforce` |`.page` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| XML | `SLD` , `XML` , `XHTML` , `XSD` , `XSL` , `JSP` |`.sld`, `.xml` , `.xhtml` , `.xsd` , `.xsl` , `.jsp` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
| XTemplate | `XTemplate` |`.xtemplate` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2014-06-15 15:37:11 -06:00
2014-03-03 00:51:16 -07:00
## Usage
2016-07-02 16:28:01 -06:00
Open the [Command Palette ](https://github.com/atom/command-palette ), type `Beautify` , and run `Beautify Editor` .
![image ](https://cloud.githubusercontent.com/assets/1885333/16542583/1c8d975c-4085-11e6-8307-e35df7430a10.png )
### Selection of Code
2014-06-12 18:33:17 -06:00
2015-06-01 06:07:51 -06:00
It will only beautify selected text if a selection is found -- if not, the whole file will be beautified.
2014-06-12 18:33:17 -06:00
2016-07-02 16:28:01 -06:00
| Selection of Code | Beautify Selection of Code | Beautify Entire File |
| --- | --- | --- |
| Select code in Atom editor | Only that selection is beautified | Without a selection all code is beautified |
| ![image ](https://cloud.githubusercontent.com/assets/1885333/16542597/b3f90c84-4085-11e6-8a0e-1b8604ae385c.png ) | ![image ](https://cloud.githubusercontent.com/assets/1885333/16542598/b5a86b10-4085-11e6-80cf-0afaf1a819c3.png ) | ![image ](https://cloud.githubusercontent.com/assets/1885333/16542603/b798ec24-4085-11e6-880e-8d3a2741940f.png ) |
### Beautify On Save
`Beautify On Save` can be enabled for each language individually.
For example, for language `HTML` go into Atom-Beautify's package settings (`Atom` ➔ `Preferences` ➔ Search for `atom-beautify` ), find `HTML` , and toggle the `Beautify On Save` option.
![atom-beautify-setup-beautify-on-save ](https://cloud.githubusercontent.com/assets/1885333/16542692/3e781e74-4089-11e6-9cf2-5a19af161093.gif )
### Keyboard Shortcut
2014-03-03 00:51:16 -07:00
2016-04-07 18:25:55 -06:00
You can also type < kbd > Ctrl</ kbd > -< kbd > Alt</ kbd > -< kbd > B</ kbd > as a shortcut or click `Packages > Beautify` in the menu.
2014-03-03 00:51:16 -07:00
2014-07-12 09:02:21 -06:00
#### Custom Keyboard Shortcuts
2015-10-10 16:01:30 -06:00
See [Keymaps In-Depth ](https://atom.io/docs/latest/behind-atom-keymaps-in-depth ) for more details.
2014-07-12 09:02:21 -06:00
For example:
```coffeescript
2015-01-01 20:34:04 -07:00
'.editor':
2015-05-06 10:00:51 -06:00
'ctrl-alt-b': 'atom-beautify:beautify-editor'
2014-07-12 09:02:21 -06:00
```
2014-06-12 18:33:17 -06:00
## Configuration
Edit your `.jsbeautifyrc` file in any of the following locations:
2014-06-15 15:37:11 -06:00
- Atom Package Settings
`Atom` ➔ `Preferences` ➔ Search for `atom-beautify`
2014-06-12 18:33:17 -06:00
- Same directory as current file
- Project root
`atom-beautify` will recursively look up from the current file's directory to find `.jsbeautifyrc` .
2015-06-01 06:07:51 -06:00
- Your user's home directory
2014-06-12 18:33:17 -06:00
2014-06-12 22:25:39 -06:00
**Note**: *Comments are supported in `.jsbeautifyrc` thanks to [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).*
2015-06-01 06:07:51 -06:00
See examples of both ways inside [`examples/` ](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples )
2014-06-12 22:25:39 -06:00
2015-06-01 13:50:09 -06:00
See [all supported options in the documentation at `docs/options.md` ](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md ).
2014-09-11 09:48:15 -06:00
2014-06-12 22:25:39 -06:00
### Simple
See [examples/simple-jsbeautifyrc/.jsbeautifyrc ](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/simple-jsbeautifyrc/.jsbeautifyrc ).
```json
{
"indent_size": 2,
"indent_char": " ",
"other": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 2,
"jslint_happy": true,
"indent_handlebars": true
}
```
2016-07-02 16:28:01 -06:00
### Nested (Recommended)
2014-06-12 22:25:39 -06:00
See [examples/nested-jsbeautifyrc/.jsbeautifyrc ](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/nested-jsbeautifyrc/.jsbeautifyrc ).
```json
{
"html": {
"brace_style": "collapse",
"indent_char": " ",
"indent_scripts": "normal",
"indent_size": 6,
"max_preserve_newlines": 1,
"preserve_newlines": true,
"unformatted": ["a", "sub", "sup", "b", "i", "u"],
"wrap_line_length": 0
},
"css": {
"indent_char": " ",
"indent_size": 4
},
"js": {
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 2,
"jslint_happy": true
2014-06-13 23:21:26 -06:00
},
"sql": {
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false
2014-06-12 22:25:39 -06:00
}
}
```
2014-06-12 21:16:39 -06:00
2016-07-02 16:28:01 -06:00
## Troubleshooting
2016-07-04 20:58:48 -06:00
See [`docs/troubleshooting.md` ](https://github.com/Glavin001/atom-beautify/blob/master/docs/troubleshooting.md ).
2016-07-02 16:28:01 -06:00
2014-06-12 18:33:17 -06:00
## Contributing
[See all contributors on GitHub ](https://github.com/donaldpipowitch/atom-beautify/graphs/contributors ).
2014-06-14 17:13:32 -06:00
Please update the [CHANGELOG.md ](https://github.com/donaldpipowitch/atom-beautify/blob/master/CHANGELOG.md ),
add yourself as a contributor to the [package.json ](https://github.com/donaldpipowitch/atom-beautify/blob/master/package.json ),
2015-12-10 09:46:07 -07:00
and submit a [Pull Request on GitHub ](https://help.github.com/articles/using-pull-requests/ ).
2014-05-19 00:04:56 -06:00
2014-03-03 00:51:16 -07:00
## License
2015-05-02 17:25:04 -06:00
[MIT ](https://github.com/donaldpipowitch/atom-beautify/blob/master/LICENSE.md ) © [Glavin Wiechert ](https://github.com/Glavin001 )