如何使用Sublime Text 2重新格式化HTML代码? [英] How do I reformat HTML code using Sublime Text 2?

查看:138
本文介绍了如何使用Sublime Text 2重新格式化HTML代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些格式不正确的HTML代码,我想重新格式化。是否有一个命令可以自动重新格式化Sublime Text 2中的HTML代码,所以它看起来更好,并且更易于阅读?

不需要任何插件来做到这一点。
只需选择所有行( Ctrl A ),然后从菜单中选择编辑&rar; Line→重新缩进。
如果您的文件以包含HTML的扩展名保存,如 .html .php



如果您经常这样做,您可能会发现这个键映射很有用:

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

如果您的文件没有保存(例如,您只是将代码段粘贴到新窗口中),则可以通过选择菜单手动设置缩进语言查看→语法→ 选择语言,然后选择重新加入选项。


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?

解决方案

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.

这篇关于如何使用Sublime Text 2重新格式化HTML代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆