Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an auto indentation option in Sublime 2?

In Visual Studio I can press Ctrl+K+D to indent everything so the code is structured nicely. Is there a shortcut in Sublime 2 to do the same?

share|improve this question
Have you checked the documentation? If it's not there it is non-existent most likely. – r4. Feb 29 '12 at 9:39
The problem isn't that it isn't there, it's that there isn't a default hot key like there is with Visual Studio. You can give it one using the keybinding - default preference files. – Valoric Mar 9 '12 at 0:31

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.

share|improve this answer

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

Press Enter and it's done.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer
And you may need to reindent the line (Edit / Line / Reindent) afterwards. – palaniraja Jul 18 '12 at 11:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.