Wednesday 5 June 2019

sublimetext2 - How do I reformat HTML code using Sublime Text 2?



I've got some poorly-formatted HTML code that I'd like to reformat. Is there a command that will automatically reformat HTML code in Sublime Text 2 so it looks better and is easier to read?


Answer



You don't need any plugins to do this.
Just select all lines (Ctrl A) and then from the menu select Edit → Line → Reindent.
This will work if your file is saved with an extension that contains HTML like .html or .php.



If you do this often, you may find this key mapping useful:




{ "keys": ["ctrl+shift+r"], "command": "reindent" , "args": { "single_line": false } }


If your file is not saved (e.g. you just pasted in a snippet to a new window), you can manually set the language for indentation by selecting the menu View → Syntax → language of choice before selecting the reindent option.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...