Sublime Text3 HTML-CSS-JS Prettify插件技巧
ctrl+shift+p输入pin回车后输入HTML-CSS-JS Prettify
设置--》package Settings--》HTML/CSS/JS Prettify--》Set Prettify Preferences粘贴下面的文字进去
{
"html": {
//html作用于以下文件
"allowed_file_extensions": ["htmlhintrc", "htm", "html", "xhtml", "shtml", "xml", "svg","vue"],
// js中花括号是否换行[collapse|expand|end-expand]
"brace_style": "collapse",
//标签缩进字符采用空格
"indent_char": " ",
//缩进大小为4个
"indent_size": 4,
//缩进是否采用制表符
"indent_with_tabs": false,
//end-of-line(EOF行结束),Line Feed(LF换行或者Line FeedNL),carriage return(CR回车符),林纳斯-->\n(光标下一行回到行首),微软-->\r\n,苹果-->\r(光标回到行首往下一行)
//Unix/Mac系统下的文件在Windows里打开的话,所有文字会变成一行(因为两个符号才表示换行);而Windows里的文件在Unix/Mac下打开的话,在每行的结尾可能会多出一个^M符号。
//以下是对行结尾的处理方式;如果需要跨平台必须把window的crlf转为lf也就是
//"eol":"\n",
//是否输出eol里的内容,默认false
"end_with_newline": false,
// 对内容中双重花括号进行缩进{{#foo}}, {{/foo}},默认为false;
"indent_handlebars": true,
//是否缩进<head>和<body>部分
"indent_inner_html": false,
// 对html中scripts的代码缩进规则[keep(保持同辈)|separate(不缩进)|normal(正常缩进)]
"indent_scripts": "normal",
//一个块中保留的最大换行数(0表示禁用);
"max_preserve_newlines": 0,
//是否应该保留元素之前的现有换行符(仅在元素之前工作,不在标签内或文本中)默认为true(保留换行符\n)
//例如设置为false;
//<dl><li>\nabc\n</li></dl>
//<dl><li>abc</li></dl>
"preserve_newlines": true,
//都不需要换行缩进的元素,默认"a", "span", "img", "code", "pre", "sub", "sup", "em", "strong", "b", "i", "u", "strike", "big", "small", "pre", "h1", "h2", "h3", "h4", "h5", "h6"
"unformatted": ["pre"],
//按字符数进行换行,0为禁用
"wrap_line_length": 0,
//使用换行符\n或空格分隔选择器
"selector_separator": "",
//选择器是否换行
"selector_separator_newline": false
}
, "css": {
//css作用于以下文件
"allowed_file_extensions": ["css", "scss", "sass", "less"],
//是否输出eol里的内容,默认false
"end_with_newline": false,
//标签缩进字符采用空格
"indent_char": " ",
//缩进大小为4个
"indent_size": 4,
//缩进是否采用制表符
"indent_with_tabs": false,
//在每个css规则之后添加一行新的
"newline_between_rules": false,
//使用换行符\n或空格分隔选择器
"selector_separator": "",
//选择器是否换行
"selector_separator_newline": false
}
, "js": {
//js作用于以下文件,变量,函数手动隔行的地方不会格式化
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
// https://github.com/victorporof/Sublime-HTMLPrettify/issues/231
// Set brace_style
// collapse
// expand
// end-expand
// none
"brace_style": "collapse",
//在后续行中断开链接方法调用
"break_chained_methods": false,
//通过E4X xml文字通过不变的
"e4x": false,
//是否输出eol里的内容,默认false
"end_with_newline": false,
//标签缩进字符采用空格
"indent_char": " ",
//缩进大小为4个
"indent_size": 4,
//初始缩进级别
"indent_level": 0,
//缩进是否采用制表符
"indent_with_tabs": false,
//是否采用jslint-stricter模式,另外的规则
"jslint_happy": false,
//保留数组缩进,(测试没效果)
"keep_array_indentation": false,
//保留函数缩进,(测试没效果)
"keep_function_indentation": false,
//在一个块中保留的最大换行数
"max_preserve_newlines": 0,
//是否保留手动换行的换行符
"preserve_newlines": true,
//"if(true)" vs "if (true)"
"space_before_conditional": true,
//"function()" vs "function ()"
"space_after_anon_function": false,
//"f()" vs "f( )"
"space_in_empty_paren": false,
//在括号内添加填充空格,例如f( a, b )
"space_in_paren": false,
//对转义字符"\x65\x78\x61\x6d\x70\x6c\x65"不格式化
"unescape_strings": true,
//按字符数进行换行,0为禁用
"wrap_line_length": 0,
//在新行开始时加上逗号,而不是结尾
"comma_first": false
}
}配置相应的快捷键即可
https://jingyan.baidu.com/article/375c8e19e5ce7c25f3a2295f.html