In the title bar, go to Preferences> Key Bindings, then add this binding to the Key Bindings - User file.
{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}
Now that you want to automatically align the code, just highlight the desired code and press alt+shift+f
Source: https://coderwall.com/p/7yxpdw/auto-indenting-on-sublime-text-3
source
share