Brackets.io: Is there a way to auto indent / format <html>
Asked Answered
R

6

55

I am new to Brackets.io and thought I saw a shortcut key to auto indent/format HTML, however I cannot find a shortcut. Is there a shortcut or add-on that will do this for me?

Readymix answered 27/12, 2015 at 8:17 Comment(1)
See superuser.com/q/838323/388554Walrath
R
83

I found an add-on for Brackets.io that uses auto-indent called Indentator.
It uses shortcut keys Ctrl + Alt + I

Readymix answered 28/12, 2015 at 7:15 Comment(4)
Did you install the Indentator add-on? I just confirmed it works well on the current version of Brackets (1.8). First go to File > Extension Manager and search for Indentator. Upon completion of installation, use Crtl + Alt + i and it should work without issue.Readymix
This works fine, but only on the whole file, not on the selected code onlyCarabiniere
For macOS the shortcut is Ctrl + Option + I.Auberon
The author clearly missed the chance to name it as the Indent-inator (you read it in Doof's voice, didn't ya?) ;)Swart
A
59

You can install an indentator package.

Click on File > Extension Manager....

Look for the search field and type: Indentator > Install

Once Indentator is installed, you can use Ctrl + Alt + I

Alcaic answered 23/2, 2017 at 22:33 Comment(4)
how do you sent the indent width?Alicealicea
In the down-right corner -> click on "tab size" (changes to "spaces") then click on the value to change it. (taken from some Brackets repository issue)Alcaic
After Indentator installation, menu is "Edit" > "Indent Document" (Ctrl + Alt + I)Cyd
Can you change the shortcut for this?Complex
F
29

Beautify does a good job. It provides a "Beautify on save" option, so that you may use ctrl+s to reformate html, less, css, etc

Fecal answered 18/2, 2016 at 9:16 Comment(2)
Beautify does more than fixing indentation. Thanks for suggesting it!Baroque
It is in edit after installation and can be called with Ctrl alt BMythologize
A
2

The shortcut key is ctrl+] to indentation and ctrl +[ to unindent

Ainsworth answered 28/9, 2020 at 12:35 Comment(0)
I
1

The Identator plugin works to me in Brackets Release 1.13 versión 1.13.0-17696 (release 49d29a8bc) on S.O. Windows 10

Isostasy answered 27/7, 2018 at 14:50 Comment(0)
R
0

I've been playing around with the preferences and added the following to my brackets.json file (access in Menu Bar: Debug: "Open Preferences File").

"closeTags": { "dontCloseTags": ["br", "hr", "img", "input", "link", "meta", "area", "base", "col", "command", "embed", "keygen", "param", "source", "track", "wbr"], "indentTags": ["ul", "ol", "div", "section", "table", "tr"], }

  • dontCloseTags are tags such as <br> which shouldn't be closed.
  • indentTags are tags that you want to automatically create a new indented line - add more as needed!
  • (any tags that aren't in above arrays will self-close on the same line)
Rousing answered 3/4, 2018 at 23:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.