Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to proper format/indent HTML and PHP Code in Sublime Text 3

im wondering if there is any Sublime Text 3 plugin besides HTML Tidy which is able to reindent or reformat parts of HTML Code

like image 978
Mik Avatar asked Dec 17 '13 15:12

Mik


People also ask

How can I beautify PHP code in Sublime Text 3?

ctrl + shift + P and type Tidy PHP , or you can use the ctrl + alt + T keybinding.

How do I beautify HTML code in Sublime Text 3?

Beautify while editing (Experimental / Sublime Text 3 only) To beautify your code when while editing a document, set the format_while_editing setting to true in HTMLPrettify.

How do I fix indentations in Sublime Text?

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.


1 Answers

Thanks a lot for your answer, but i found a nice, built in approach of sublime text. Just select everything (CTRL + a (Windows) or CMD + a (Mac) and click this in the menu

Edit → Line → Reindent

maybe this helps also others

EDIT(2017): You can also use key combination (without need for mouse)

CTRL + SHIFT + P (Windows)
CMD + SHIFT + P (Mac)

then type 'Reindent' and select the fist option 'Indentation: Reindent Lines'

like image 71
Mik Avatar answered Oct 04 '22 21:10

Mik