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.
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.
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:
You can use one of many plugins which do the thing you need, for example, the one I am using:
This should work as at sublime text version 3 :
{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}
just copy and paste to your preferences->keybindings->User file.
Now select the entire code and press alt shift f to see the results.
For intending purpose you can use Ctrl plus ] and to unintend use Ctrl plus [
For C/C++/C#/Java code, you can try SublimeAStyleFormatter
For PHP/JavaScript/JSON/HTML/CSS/Python/Go Code, you can try CodeFormatter
Take SublimeAStyleFormatter as an example:
⌘+⇧+P on OS X. Ctrl+Shift+P on Windows and Linux.).The “Packages” directory is located at:
%APPDATA%\Sublime Text 3\Packages~/.config/sublime-text-3/Packages/~/Library/Application Support/Sublime Text 3/Packages/Windows, Linux:
OSX:
For example, on macOS, install the SublimeAStyleFormatter plug-in, and then press the Ctrl+Alt+F shortcut key, and then you can Autoindent.