Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set HTML Auto Indent format on Sublime Text 3?

I have a question while I'm writing HTML code on Sublime Text 3. I just want to set auto indent format of HTML. For example, when I write p tag like under code, the indentation works like that.

<p> Hello world! </p> 

But I want to write like under code instead of above.

<p>   Hello world! </p> 

And not only p tag also ul, ol and etc.

How can I set auto indent format of HTML on Sublime Text 3?

like image 430
Originerd Avatar asked Jan 17 '14 15:01

Originerd


People also ask

How do I beautify HTML code in Sublime Text 3?

Beautify on Save sublime-settings : Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X.

How do I change the default indentation in Sublime Text 3?

Changing default indentation settings The following File Type Preferences determine the indentation settings: translateTabsToSpaces: set to either 'true' or 'false'. If true, then when tab is pressed, an equivalent number of spaces will be inserted into the buffer instead. Defaults to false.

How do I fix sublime indentations?

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.


1 Answers

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.

Another option is to install the Emmet plugin (http://emmet.io/), which will provide not only better formatting, but also a myriad of other incredible features. To get the output you're looking for using Sublime Text 3 with the Emmet plugin requires just the following:

p [tab][enter] Hello world! 

When you type p [tab] Emmet expands it to:

<p></p> 

Pressing [enter] then further expands it to:

<p>  </p> 

With the cursor indented and on the line between the tags. Meaning that typing text results in:

<p>     Hello, world! </p> 
like image 193
jlbnjmn Avatar answered Oct 09 '22 07:10

jlbnjmn