2016-07-02 16:28:01 -06:00
# :lipstick: [atom-beautify](https://github.com/Glavin001/atom-beautify)
2017-04-15 11:31:55 -06:00
[![GitHub issues ](https://img.shields.io/github/issues/Glavin001/atom-beautify.svg?style=flat-square )](https://github.com/Glavin001/atom-beautify/issues)
[![GitHub stars ](https://img.shields.io/github/stars/Glavin001/atom-beautify.svg?style=flat-square )](https://github.com/Glavin001/atom-beautify/stargazers)
[![Gitter ](https://img.shields.io/gitter/room/Glavin001/atom-beautify.svg?style=flat-square )](https://gitter.im/Glavin001/atom-beautify)
[![Bountysource ](https://img.shields.io/bountysource/team/atom-beautify/activity.svg?style=flat-square )](https://www.bountysource.com/teams/atom-beautify)
[![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)
2014-03-03 00:51:16 -07:00
2016-09-25 16:45:21 -06:00
| Mac OS < img src = "https://cloud.githubusercontent.com/assets/1885333/17059766/2530c9d8-4ffd-11e6-9529-3fa47dbff616.png" width = "50px" > and < 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" > |
2016-09-25 16:48:16 -06:00
| --- | --- |
2017-04-15 11:31:55 -06:00
| [Travis CI: ![Travis branch ](https://img.shields.io/travis/Glavin001/atom-beautify/master.svg?style=flat-square )](https://travis-ci.org/Glavin001/atom-beautify) | [AppVeyor: ![AppVeyor branch ](https://img.shields.io/appveyor/ci/Glavin001/atom-beautify/master.svg?style=flat-square )](https://ci.appveyor.com/project/Glavin001/atom-beautify) |
2015-06-04 11:59:35 -06:00
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 )
2017-04-09 23:53:34 -06:00
- [Beautifiers ](#beautifiers )
2016-07-02 16:28:01 -06:00
- [Language Support ](#language-support )
- [Usage ](#usage )
2017-05-06 14:27:28 -06:00
- [Command Palette ](#command-palette )
- [Beautify a Specific Language ](#beautify-a-specific-language )
2016-07-02 16:28:01 -06:00
- [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`
2016-08-25 10:56:01 -06:00
### Important Notice: Analytics
2017-04-20 08:01:18 -06:00
[Atom-Beautify respects the `core.telemetryConsent` configuration option from Atom editor. ](https://github.com/Glavin001/atom-beautify/issues/1179 )
If you do not wish to have usage data sent to Google Analytics then please set `core.telemetryConsent` to `no` or `undecided` option before using Atom-Beautify.
2016-11-20 02:24:36 -07:00
See [`Anonymous Analytics` section of docs ](docs/options.md#anonymous-analytics ) for details.
2016-08-25 10:56:01 -06:00
Thank you.
2017-04-20 08:01:18 -06:00
| On Atom Load | Change Setting Later |
| --- | --- |
| ![image ](https://cloud.githubusercontent.com/assets/1885333/25234140/947b1b50-25b7-11e7-8ebc-0ae37420f13e.png ) | ![image ](https://cloud.githubusercontent.com/assets/1885333/25234184/b41b4192-25b7-11e7-8185-a83829b48078.png ) |
2016-09-25 22:12:16 -06:00
### Next Version: [Unibeautify](https://github.com/Unibeautify/unibeautify)
Atom-Beautify is going to be completely rewritten with [Unibeautify ](https://github.com/Unibeautify/unibeautify ) at its core!
2016-11-20 02:24:36 -07:00
See [`unibeautify` branch ](../../tree/unibeautify ) for work in progress and [Issue #1174 ](https://github.com/Glavin001/atom-beautify/issues/1174 ).
2016-09-25 22:12:16 -06:00
2017-06-04 12:19:18 -06:00
### Want automated installation?
See [Issue #1678 ](https://github.com/Glavin001/atom-beautify/issues/1687 ) for a solution utilizing [Docker ](https://www.docker.com/ ) to achieve automated installation of beautifiers which are not already preinstalled.
2017-04-09 23:53:34 -06:00
## Beautifiers
Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them.
| Beautifier | Is Pre-Installed? | Installation Instructions |
2017-04-09 23:55:56 -06:00
| --- | --- | --- |
2017-04-15 18:03:25 -06:00
| align-yaml | :white_check_mark: | Nothing! |
2017-04-09 23:53:34 -06:00
| autopep8 | :x: | Go to https://github.com/hhatto/autopep8 and follow the instructions. |
| beautysh | :x: | Go to https://github.com/bemeurer/beautysh and follow the instructions. |
| clang-format | :x: | Go to https://clang.llvm.org/docs/ClangFormat.html and follow the instructions. |
| cljfmt | :white_check_mark: | Nothing! |
| Coffee Formatter | :white_check_mark: | Nothing! |
| coffee-fmt | :white_check_mark: | Nothing! |
| Crystal | :x: | Go to http://crystal-lang.org and follow the instructions. |
| CSScomb | :white_check_mark: | Nothing! |
| dfmt | :x: | Go to https://github.com/Hackerpilot/dfmt and follow the instructions. |
| elm-format | :x: | Go to https://github.com/avh4/elm-format and follow the instructions. |
| erl_tidy | :x: | Go to http://erlang.org/doc/man/erl_tidy.html and follow the instructions. |
2017-04-10 00:46:06 -06:00
| ESLint Fixer | :white_check_mark: | Nothing! |
2017-04-09 23:53:34 -06:00
| formatR | :x: | Go to https://github.com/yihui/formatR and follow the instructions. |
| Fortran Beautifier | :x: | Go to https://www.gnu.org/software/emacs/ and follow the instructions. |
| Gherkin formatter | :white_check_mark: | Nothing! |
| gofmt | :x: | Go to https://golang.org/cmd/gofmt/ and follow the instructions. |
| hh_format | :x: | Go to http://hhvm.com/ and follow the instructions. |
| HTML Beautifier | :x: | Go to https://github.com/threedaymonk/htmlbeautifier and follow the instructions. |
| JS Beautify | :white_check_mark: | Nothing! |
| JSCS Fixer | :white_check_mark: | Nothing! |
| Latex Beautify | :x: | Go to https://github.com/cmhughes/latexindent.pl and follow the instructions. |
2017-05-31 23:54:09 -06:00
| Lua beautifier | :white_check_mark: | Nothing! |
2017-04-09 23:53:34 -06:00
| Marko Beautifier | :white_check_mark: | Nothing! |
2017-04-20 07:17:38 -06:00
| Nginx Beautify | :white_check_mark: | Nothing! |
2017-04-09 23:53:34 -06:00
| ocp-indent | :x: | Go to https://www.typerex.org/ocp-indent.html and follow the instructions. |
| Perltidy | :x: | Go to http://perltidy.sourceforge.net/ and follow the instructions. |
| PHP-CS-Fixer | :x: | Go to https://github.com/FriendsOfPHP/PHP-CS-Fixer and follow the instructions. |
| PHPCBF | :x: | Go to http://php.net/manual/en/install.php and follow the instructions. |
| Pretty Diff | :white_check_mark: | Nothing! |
| Pug Beautify | :white_check_mark: | Nothing! |
| puppet-lint | :x: | Go to http://puppet-lint.com/ and follow the instructions. |
2017-04-15 00:16:36 -06:00
| pybeautifier | :x: | Go to https://github.com/guyskk/pybeautifier and follow the instructions. |
2017-04-09 23:53:34 -06:00
| Remark | :white_check_mark: | Nothing! |
| Rubocop | :x: | Go to https://github.com/bbatsov/rubocop and follow the instructions. |
| Ruby Beautify | :x: | Go to https://github.com/erniebrodeur/ruby-beautify and follow the instructions. |
| rustfmt | :x: | Go to https://github.com/nrc/rustfmt and follow the instructions. |
| SassConvert | :x: | Go to http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax and follow the instructions. |
| sqlformat | :x: | Go to https://github.com/andialbrecht/sqlparse and follow the instructions. |
| stylish-haskell | :x: | Go to https://github.com/jaspervdj/stylish-haskell and follow the instructions. |
| Tidy Markdown | :white_check_mark: | Nothing! |
| TypeScript Formatter | :white_check_mark: | Nothing! |
| Uncrustify | :x: | Go to https://github.com/uncrustify/uncrustify and follow the instructions. |
| Vue Beautifier | :white_check_mark: | Nothing! |
| yapf | :x: | Go to https://github.com/google/yapf and follow the instructions. |
2016-09-25 22:12:16 -06:00
2014-06-12 22:25:39 -06:00
## Language Support
2016-11-20 02:24:36 -07:00
See [all supported options in the documentation at `docs/options.md` ](docs/options.md ).
2016-07-02 16:28:01 -06:00
| 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) |
2016-09-27 14:39:56 -06:00
| Bash | `Shell Script` |`.bash`, `.sh` | [`beautysh` ](https://github.com/bemeurer/beautysh ) (Default) |
2016-07-02 16:28:01 -06:00
| 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) |
2016-09-11 18:14:44 -06:00
| Clojure | `Clojure` |`.clj`, `.cljs` , `.edn` | [`cljfmt` ](https://github.com/snoe/node-cljfmt ) (Default) |
2016-07-02 16:28:01 -06:00
| CoffeeScript | `CoffeeScript` |`.coffee` | [`Coffee Formatter` ](https://github.com/Glavin001/Coffee-Formatter ), [`coffee-fmt` ](https://github.com/sterpe/coffee-fmt ) (Default) |
2017-04-10 01:39:42 -06:00
| C++ | `C++` |`.h`, `.hh` , `.cc` , `.cpp` , `.cxx` , `.C` , `.cu` , `.c++` , `.hpp` , `.hxx` , `.h++` , `.cuh` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default), [`clang-format` ](https://clang.llvm.org/docs/ClangFormat.html ) |
2016-07-02 16:28:01 -06:00
| Crystal | `Crystal` |`.cr` | [`Crystal` ](http://crystal-lang.org ) (Default) |
| C# | `C#` |`.cs` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
2016-08-26 00:02:59 -06:00
| 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 ), [`SassConvert` ](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax ) |
2016-07-02 16:28:01 -06:00
| 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 ) |
2016-12-29 17:08:03 -07:00
| EJS | `EJS` , `JavaScript Template` , `HTML (Angular)` |`.ejs` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
2016-07-02 16:28:01 -06:00
| 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) |
2017-04-09 23:53:34 -06:00
| Fortran | `Fortran - Modern` |`.f90`, `.F90` , `.f95` , `.F95` | [`Fortran Beautifier` ](https://www.gnu.org/software/emacs/ ) (Default) |
2016-07-02 16:28:01 -06:00
| gherkin | `Gherkin` |`.feature` | [`Gherkin formatter` ](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee ) (Default) |
2016-12-05 07:05:43 -07:00
| GLSL | `C` , `opencl` , `GLSL` |`.vert`, `.frag` | [`clang-format` ](https://clang.llvm.org/docs/ClangFormat.html ) (Default) |
2016-07-02 16:28:01 -06:00
| Go | `Go` |`.go` | [`gofmt` ](https://golang.org/cmd/gofmt/ ) (Default) |
2017-01-12 15:27:28 -07:00
| Golang Template | `HTML (Go)` , `Go Template` |`.gohtml` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2016-07-02 16:28:01 -06:00
| 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) |
2017-04-10 00:46:06 -06:00
| JavaScript | `JavaScript` |`.js` | [`ESLint Fixer` ](https://github.com/eslint/eslint ), [`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 ) |
2016-07-02 16:28:01 -06:00
| JSON | `JSON` |`.json` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
2016-12-29 18:27:06 -07:00
| JSX | `JSX` , `JavaScript (JSX)` , `Babel ES6 JavaScript` , `JavaScript with JSX` |`.jsx`, `.js` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2017-04-20 18:41:06 -06:00
| LaTeX | `BibTeX` , `LaTeX` , `TeX` |`.bib`, `.tex` , `.sty` , `.cls` , `.dtx` , `.ins` , `.bbx` , `.cbx` | [`Latex Beautify` ](https://github.com/cmhughes/latexindent.pl ) (Default) |
2016-07-02 16:28:01 -06:00
| LESS | `LESS` |`.less` | [`CSScomb` ](https://github.com/csscomb/csscomb.js ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2017-05-31 23:54:09 -06:00
| Lua | `Lua` |`.lua` | [`Lua beautifier` ](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.coffee ) (Default) |
2016-07-02 16:28:01 -06:00
| 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) |
2017-04-12 15:59:38 -06:00
| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ) (Default), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) |
2017-04-14 23:27:12 -06:00
| Nginx | `nginx` |`.conf` | [`Nginx Beautify` ](https://github.com/denysvitali/nginxbeautify ) (Default) |
2016-09-11 15:48:16 -06:00
| Nunjucks | `Nunjucks` , `Nunjucks Templates` , `HTML (Nunjucks Templates)` |`.njk`, `.nunjucks` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2016-07-02 16:28:01 -06:00
| 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) |
2017-04-17 11:34:42 -06:00
| Perl | `Perl` , `Perl 6` |`.pl`, `.PL` , `.pm` , `.pod` , `.t` | [`Perltidy` ](http://perltidy.sourceforge.net/ ) (Default) |
2016-12-29 22:58:15 -07:00
| PHP | `PHP` |`.php`, `.module` , `.inc` | [`PHP-CS-Fixer` ](https://github.com/FriendsOfPHP/PHP-CS-Fixer ) (Default), [`PHPCBF` ](http://php.net/manual/en/install.php ), [`hh_format` ](http://hhvm.com/ ) |
2016-07-02 16:28:01 -06:00
| Puppet | `Puppet` |`.pp` | [`puppet-lint` ](http://puppet-lint.com/ ) (Default) |
2016-11-20 02:24:36 -07:00
| Python | `Python` |`.py` | [`autopep8` ](https://github.com/hhatto/autopep8 ) (Default), [`pybeautifier` ](https://github.com/guyskk/pybeautifier ), [`yapf` ](https://github.com/google/yapf ) |
2016-09-02 03:15:30 -06:00
| R | `R` |`.r`, `.R` | [`formatR` ](https://github.com/yihui/formatR ) (Default) |
2016-07-02 16:28:01 -06:00
| 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) |
2016-08-17 23:23:15 -06:00
| Sass | `Sass` |`.sass` | [`SassConvert` ](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax ) (Default) |
2016-08-26 00:02:59 -06:00
| SCSS | `SCSS` |`.scss` | [`CSScomb` ](https://github.com/csscomb/csscomb.js ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default), [`SassConvert` ](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax ) |
2016-07-02 16:28:01 -06:00
| 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) |
2016-09-11 18:14:44 -06:00
| UX Markup | `UX` |`.ux` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2016-07-02 16:28:01 -06:00
| Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify` ](https://github.com/uncrustify/uncrustify ) (Default) |
| Visualforce | `Visualforce` |`.page` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2017-04-09 23:53:34 -06:00
| Vue | `Vue Component` |`.vue` | [`Vue Beautifier` ](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee ) (Default) |
2017-05-27 23:28:35 -06:00
| XML | `SLD` , `XML` , `XHTML` , `XSD` , `XSL` , `JSP` , `GSP` |`.sld`, `.xml` , `.xhtml` , `.xsd` , `.xsl` , `.jsp` , `.gsp` , `.plist` , `.recipe` , `.config` | [`JS Beautify` ](https://github.com/beautify-web/js-beautify ), [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2016-07-02 16:28:01 -06:00
| XTemplate | `XTemplate` |`.xtemplate` | [`Pretty Diff` ](https://github.com/prettydiff/prettydiff ) (Default) |
2017-04-15 18:03:25 -06:00
| YAML | `YAML` |`.yml`, `.yaml` | [`align-yaml` ](https://github.com/jonschlinkert/align-yaml ) (Default) |
2014-06-15 15:37:11 -06:00
2014-03-03 00:51:16 -07:00
## Usage
2017-05-06 14:27:28 -06:00
### Command Palette
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 )
2017-05-06 14:27:28 -06:00
#### Beautify a Specific Language
You can use the [Command Palette ](https://github.com/atom/command-palette ) to beautify the editor for a specific language.
The commands are in the form `Atom Beautify: Beautify Language {NAME}` (i.e. `atom-beautify:beautify-language-{NAME}` for keyboard shortcuts).
For example, you may want to beautify `JavaScript` code within a `HTML` file.
![atom-beautify-language-commands ](https://cloud.githubusercontent.com/assets/1885333/25775586/f3fc7ec4-327e-11e7-8576-45e735e80032.gif )
2016-07-02 16:28:01 -06:00
### 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:
2016-11-20 02:24:36 -07:00
- Atom Package Settings
2014-06-15 15:37:11 -06:00
`Atom` ➔ `Preferences` ➔ Search for `atom-beautify`
2014-06-12 18:33:17 -06:00
- Same directory as current file
2016-11-20 02:24:36 -07:00
- Project root
2014-06-12 18:33:17 -06:00
`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).*
2016-11-20 02:24:36 -07:00
See examples of both ways inside [`examples/` ](examples )
2014-06-12 22:25:39 -06:00
2016-11-20 02:24:36 -07:00
See [all supported options in the documentation at `docs/options.md` ](docs/options.md ).
2014-09-11 09:48:15 -06:00
2014-06-12 22:25:39 -06:00
### Simple
2016-11-20 02:24:36 -07:00
See [examples/simple-jsbeautifyrc/.jsbeautifyrc ](examples/simple-jsbeautifyrc/.jsbeautifyrc ).
2014-06-12 22:25:39 -06:00
```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
2016-11-20 02:24:36 -07:00
See [examples/nested-jsbeautifyrc/.jsbeautifyrc ](examples/nested-jsbeautifyrc/.jsbeautifyrc ).
2014-06-12 22:25:39 -06:00
```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-11-20 02:24:36 -07:00
See [`docs/troubleshooting.md` ](docs/troubleshooting.md ).
2016-07-02 16:28:01 -06:00
2014-06-12 18:33:17 -06:00
## Contributing
2016-11-20 02:24:36 -07:00
[See all contributors on GitHub ](../../graphs/contributors ).
2014-06-12 18:33:17 -06:00
2016-11-20 02:24:36 -07:00
Please update the [CHANGELOG.md ](CHANGELOG.md ),
add yourself as a contributor to the [package.json ](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
2016-11-20 02:24:36 -07:00
[MIT ](LICENSE.md ) © [Glavin Wiechert ](https://github.com/Glavin001 )