SublimeText插件之CodeFormatter

CodeFormatter插件用来对代码进行格式化,使用方式,快捷键 ctrl+alt+f

codeformatter是Sublime Text 2 / 3的插件,支持格式(美化)源代码。

CodeFormatter支持的语言:

  • PHP - By phpfmt
  • JavaScript/JSON - By JSBeautifier
  • HTML - By Custom fork of BeautifulSoup
  • CSS - By JSBeautifier
  • SCSS - By Nishutosh Sharma
  • Python - By PythonTidy (only ST2)
  • Visual Basic/VBScript
  • Coldfusion/Railo/Lucee

下载方式:将Git源代码,clone到Sublime Text插件目录


Git地址:

https://github.com/akalongman/sublimetext-codeformatter

https://github.com/akalongman/sublimetext-codeformatter.git

PackageControl官网地址:

https://packagecontrol.io/packages/CodeFormatter

更多插件地址:

https://packagecontrol.io/


特别注意,对于HTML格式化的配置:

    "codeformatter_html_options":
    {
        "syntaxes": "html,blade,asp,xml", // Syntax names which must process HTML formatter
        "format_on_save": true, // Format on save
        "formatter_version": "regexp", // Which formatter to use. Current options are "bs4" and "regexp". If an error occurs while loading the bs4 formatter, the regexp formatter will automatically be used
        "indent_size": 4, // indentation size
        "indent_char": " ", // Indentation character
        "indent_with_tabs": true, // Indent with one tab (overrides indent_size and indent_char options)
        "exception_on_tag_mismatch": false, // If the last closing tag is not at the same indentation level as the first opening tag, there's probably a tag mismatch in the file
        "expand_javascript": true, // (Under construction) Expand JavaScript inside of <script> tags (also affects CSS purely by coincidence)
        "expand_tags": true, // Expand tag attributes onto new lines
        "minimum_attribute_count": 2, // Minimum number of attributes needed before tag attributes are expanded to new lines
        "first_attribute_on_new_line": false, // Put all attributes on separate lines from the tag (only uses 1 indentation unit as opposed to lining all attributes up with the first)
        "reduce_empty_tags": true, // Put closing tags on same line as opening tag if there is no content between them
        "custom_singletons": "" // Custom singleton tags for various template languages outside of the HTML5 spec
    },

1. 格式化模式使用regexp比较理想

"formatter_version": "regexp", 

2.启用保存时格式化,很不错

"format_on_save": true, // Format on save


更多插件:

Sublime Text插件之Css3

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值