Autoindentation in Sublime 2 text editor

You can use the Edit / Line / Reindent from the edit menu. Or you could try adding this to your keybindings - Default file from preferences.

{ "keys": ["f12"], "command": "reindent"}

Add a comma at the end of the code if you use the Default file instead of the users. Don't forget to select what you want indented.

You could potentially just use Visual Studio to auto-indent more obscure data that SubT can't or doesn't do well.

Good luck && select the text you want to reindent.


Press Ctrl+Shift+P, then I, and the option "Indentation : Reindent Lines" should come first.

Press Enter and it's done.


For the built in solution I like to add the option single_line: false to the key binding, as suggested by peter on this StackOverflow thread.

{ "keys": ["ctrl+k+d"], "command": "reindent" , "args": {"single_line": false}}

But this does not add new lines, as you should expect on some XML and HTML code editing.

For those you should follow Tom's answer and install the Tag plugin, or use the Indent XML plugin, available also via package control but works only on XML files.

If you choose the Tag plugin, the easiest way to use it is highlight the text to indent and then press the shortcut Ctrl+Shift+F.

If you choose the Indent XML plugin press Ctrl or Super+Shift+P and then I and the Indent XML will be the first option.


There is a tag plugin for formatting html/xml documents.