崇高文字缩进问题 [英] Sublime Text indentation issue
本文介绍了崇高文字缩进问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在组合html和jsp标记时遇到了缩进问题.
I encountered an indentation issue while combining html and jsp tags.
复制步骤:
- 文件>新文件(Ctrl + N)
- 视图>语法> Java> Java服务器页面(JSP)
- 粘贴以下代码:
<ul>
<c:if test="${a > 0}">
<li>a</li>
</c:if>
</ul>
- 选择所有内容(Ctrl + A)并运行Ctrl + Shift + P>缩进:重新缩进行
- 结果是:
<ul>
<c:if test="${a > 0}">
<li>a</li>
</c:if>
</ul>
已测试在Windows 7 x64下运行Build 3047.
Tested running Build 3047 under Windows 7 x64.
有任何线索吗?
推荐答案
对于ST2:
打开html包并编辑Packages/HTML/Miscellaneous.tmPreferences
文件.
Open the html package and edit the Packages/HTML/Miscellaneous.tmPreferences
file.
将文本替换为下面的文本.以下正则表达式接受<c:if>
格式&的基本jsp标记. JSP注释.这不会格式化片段.
Replace the text with the one below. The below regex accepts basic jsp tags in <c:if>
format & JSP comments. This will not format scriplets.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Miscellaneous</string>
<key>scope</key>
<string>text.html</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>(?x)
^\s*
(</(?!html)
([A-Za-z0-9]+(:[A-Za-z0-9]+)?)\b[^>]*>
|-->
|--%>
|<\?(php)?\s+(else(if)?|end(if|for(each)?|while))
|\}
)</string>
<key>increaseIndentPattern</key>
<string>(?x)
^\s*
<(?!\?|area|base|br|col|frame|hr|html|img|input|link|meta|param|[^>]*/>)
([A-Za-z0-9]+(:[A-Za-z0-9]+)?)(?=\s|>)\b[^>]*>(?!.*</\1>)
|<!--(?!.*-->)
|<%--(?!.*--%>)
|<\?php.+?\b(if|else(?:if)?|for(?:each)?|while)\b.*:(?!.*end\1)
|\{[^}"']*$
</string>
<key>bracketIndentNextLinePattern</key>
<string><!DOCTYPE(?!.*>)</string>
</dict>
</dict>
</plist>
重新启动Sublime Text
这篇关于崇高文字缩进问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文