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

前端 未结 4 565
小鲜肉
小鲜肉 2020-12-08 13:25

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 indenta

4条回答
  •  有刺的猬
    2020-12-08 14:09

    This was bugging me too, since this was a standard feature in Sublime Text 2, but somehow automatic indentation no longer worked in Sublime Text 3 for HTML files.

    My solution was to find the Miscellaneous.tmPreferences file from Sublime Text 2 (found under %AppData%/Roaming/Sublime Text 2/Packages/HTML) and copy those settings to the same file for ST3.

    Now package handling has been made more difficult for ST3, but luckily you can just add the files to your %AppData%/Roaming/Sublime Text 3/Packages folder and they overwrite default settings in the install directory. Just save this file as "%AppData%/Roaming/Sublime Text 3/Packages/HTML/Miscellaneous.tmPreferences" and auto indent works again like it did in ST2.

    
    
    
    
        name
        Miscellaneous
        scope
        text.html
        settings
        
            decreaseIndentPattern
                (?x)
                ^\s*
                (</(?!html)
                  [A-Za-z0-9]+\b[^>]*>
                |-->
                |<\?(php)?\s+(else(if)?|end(if|for(each)?|while))
                |\}
                )
            batchDecreaseIndentPattern
                (?x)
                ^\s*
                (</(?!html)
                  [A-Za-z0-9]+\b[^>]*>
                |-->
                |<\?(php)?\s+(else(if)?|end(if|for(each)?|while))
                |\}
                )
            increaseIndentPattern
                (?x)
                ^\s*
                <(?!\?|area|base|br|col|frame|hr|html|img|input|link|meta|param|[^>]*/>)
                  ([A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*</\1>)
                |<!--(?!.*-->)
                |<\?php.+?\b(if|else(?:if)?|for(?:each)?|while)\b.*:(?!.*end\1)
                |\{[^}"']*$
                
            batchIncreaseIndentPattern
                (?x)
                ^\s*
                <(?!\?|area|base|br|col|frame|hr|html|img|input|link|meta|param|[^>]*/>)
                  ([A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*</\1>)
                |<!--(?!.*-->)
                |<\?php.+?\b(if|else(?:if)?|for(?:each)?|while)\b.*:(?!.*end\1)
                |\{[^}"']*$
                
            bracketIndentNextLinePattern
             <!DOCTYPE(?!.*>)
        
    
    
    

提交回复
热议问题