Are there any command/shortcut to auto-indent all my code on the page at once on Sublime Text 3?
e.g: On NetBeans I can do this with Alt+Shift+F.
To configure the tab width in Sublime Text 3, click on “View” in the top bar, then click on “Indentation” in the drop-down list. Next, in the second level of the drop-down list select the width you want a tab to take up. Sublime Text 3 defaults to tabs being four spaces wide.
sublime-settings : Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X. type htmlprettify , select Set Plugin Options.
Ensure tab width is set to 2. Convert your 2-space indentation to tabs, switch to tab width 4, and then convert the indentation back to spaces.
One option is to type [command] + [shift] + [p] (or the equivalent) and then type 'indentation'. The top result should be 'Indendtation: Reindent Lines'. Press [enter] and it will format the document.
That's quite simple in Sublime. Just Ctrl+Shift+P
(or Command+Shift+P
on MacOS) to open the tools pallet, type reindent
, and pick Indentation: Reindent Lines
. It should reindent all the file you are in, just remember to save before running the command, or it may not appear.
Just add this binding to your "Key Bindings - User" file:
Preferences > Key Bindings - users
{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}
And adding this code between the square brackets.
Now you can use Alt + Shift + f as your auto-indent shortcut
You can also use the "reindent" feature through the command palette. Ctrl + Shift + P
Ressources:
Auto-indenting on Sublime Text 3 by Osvaldo Zonetti
Create a Keybinding by Joe Lloyd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With