Sublime Text 2: formatting HTML tag content in one line

Well, my situation is slightly different from all topics related to HTML formatting. In addition, I installed every HTML formatting plugin there with mixed results and no one will solve my problem.

In addition, configuring these plugins can be difficult, as I am not a programmer, and some authors do not provide sufficient information to configure their plugins.

Currently, the only plugin that formats my HTML somewhat Ok is HTMLTidy , the problem is that it uses too much space for each tag. See my example below.

I also tried what they mentioned in this thread , and it only works to some extent, like indentation, but not for "true" markup formatting.

All I want to do is rotate this markup:

<ul>
   <li>
     item here
   </li>
   <li>
     item here
   </li>
   <li>
     item here
   </li>
</ul>

Or this one:

<p>
   Content...
</p>

In it:

<ul>
   <li>item here</li>
   <li>item here</li>
   <li>item here</li>
</ul>

And this:

 <p>Content...</p>

Keeping each tag on a separate line of opening / closing tags is a waste of time for me.

Any idea how to do this, either modifying something in TidyHTML, either manually or in any other way?

Thanks in advance.

+4
source share
3 answers

Note. This solution only works in ST2, because at this point (7/31/14) HTMLTidy is not available for ST3.

I thought of a workaround, not an ideal in any way, but ...

  • : Preferences -> Key Bindings - User. Default (Windows).sublime-keypmap.

  • ( , []):

     [
       { "keys": ["ctrl+shift+r"], "command": "reindent" , "args": {"single_line": false}},
       //Indent code -- http://stackoverflow.com/questions/8839753/formatting-html-code-using-sublime-text-2
    
       { "keys": ["ctrl+alt+t"], "command": "html_tidy"}
       //HTMLTidy key binding
     ]
    
  • .

  • , HTMLTidy. HTMLTidy HtmlTidy.sublime-settings: Preferences -> Package Settings -> HtmlTidy -> Settings - Default.

  • "indent": true, ( ) false.

  • .

  • HTML , . , , o_O. <body>, (<html>, <head> ..).

  • CTRL + ALT + T, TidyHTML. .

  • , CTRL + SHIFT + R, .

.

+4

, <li>, alt+f3 , , ctrl+d, ctrl+j . !

ctrl+shift+j . , .

+2

, F12

goto → -

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

. http://how-to-sublime-text.blogspot.com/2014/11/reformat-code.html

0

All Articles