This is a Sublime Text 2 and 3 plugin allowing you to format your HTML, CSS, JavaScript, JSON, React and Vue code. It uses a set of nice beautifier scripts made by Einar Lielmanis. The formatters are written in JavaScript, so you'll need something (node.js) to interpret JavaScript code outside the browser. Show
This will work with either HTML, CSS, JavaScript, JSON, React and Vue files. InstallationFirst of all, be sure you have installed in order to run the beautifier. After you've installed node.js, you will need to setup this plugin. Each OS has a different The shorter way of doing this is:
ManuallyMake sure you use the right Sublime Text folder. For example, on OS X, packages for version 2 are in { "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } }5, while version 3 is labeled { "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } }6. These are for Sublime Text 3: Mac{ "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } }7 Linux{ "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } }8 Windows{ "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } }9 UsageTools -> Command Palette ( { "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } }0 or Ctrl+Shift+P ) and type { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }2. – or – { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }3 (or { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }4 if you're on a Mac). – or – Right click in the current buffer and select { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }5 -> { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }6. – or – Open a HTML, CSS, JavaScript, JSON, React or Vue file, pop out the console in Sublime Text from View -> Show Console, and type { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }7. Writing commands in the console is ugly. Set up your own key combo for this, by going to Preferences -> Key Bindings - User, and adding a command in that array: { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }8. You can use any other command you want, thought most of them are already taken. Oh noez, command not found!If you get an error about Node.js not being found or similar, you don't have { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }9 in the right path. Try setting the absolute path to node in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0.
Simply using { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } }9 without specifying a path sometimes doesn't work :( For example, on Linux the path could be in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */6. On Windows, the absolute path to node.exe must use forward slashes. Must include nodejs.exe, like so: /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */7 Be very careful on Linux!Depending on your distribution and default package sources, /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */8 (for example) will not install node.js, contrary to all human common sense and popular belief. You want /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */9 instead. Best thing is to make it yourself from . Beautify VueTo properly beautify Vue files, make sure the file syntax is recongnized by Sublime as either HTML, XML or Vue. Beautify JSXTo properly beautify JSX files, make sure the file syntax is recongnized by Sublime as JavaScript and that var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */0 is var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */1 in your var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2. Beautify on SaveTo beautify your code when saving the document, set the var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */3 setting to var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */1 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0:
Beautify while editing (Experimental / Sublime Text 3 only)To beautify your code when while editing a document, set the { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }0 setting to var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */1 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. Auto-beautify when opening, focusing or bluring a file (Sublime Text 3 only)To beautify your code when on any of these events, set the { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }3, { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }4, { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }5 settings to var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */1 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. Formatting selected text onlyTo stop beautifying only the selected text, set the { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }8 setting to { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }9 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. Saving to a temporary file before prettifyingBefore prettifying, a copy of the the current editor's text contents are saved to a temporary file. This avoids piping the text directly to the prettifier, avoiding “filename or extension is too long” errors on Windows or any potential data lowss. To operate on the original document instead, set the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }1 setting to { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }9 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. Specifying which files are allowed to be prettifiedTo add different file extensions use { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }4 or { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }5 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0, under the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }7 setting. If the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }8 setting is false, then the following apply: { "html": { "allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg"], }, "css": { "allowed_file_extensions": ["css", "scss", "sass", "less"] }, "js": { "allowed_file_extensions": ["js"] }, "json": { "allowed_file_extensions": ["json", "jshintrc", "jsbeautifyrc"], } } If the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }8 setting is true, then the following apply: { "html": { "allowed_file_syntaxes": ["html", "xml"], }, "css": { "allowed_file_syntaxes": ["css", "sass", "less"], }, "js": { "allowed_file_syntaxes": ["javascript", "ecma"], }, "json": { "allowed_file_syntaxes": ["json"], } } Ignoring certain filesTo add ignore rules use /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0, under the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }7 setting. If the file (including path) matches any of the regexp patterns defined in Packages 0 it will not be beautified.The following apply regardless of the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }8 setting's value: { "html": { "disallowed_file_patterns": ["myFileToSkip\\.html", "myFolderToSkip"] }, "css": { "disallowed_file_patterns": ["myFileToSkip\\.css", "myFolderToSkip"] }, "js": { "disallowed_file_patterns": ["myFileToSkip\\.js", "myFolderToSkip"] }, "json": { "disallowed_file_patterns": ["myFileToSkip\\.json", "myFolderToSkip"] } } Ignoring certain blocks of codeParts of code that shouldn't be formatted can be ignored with Use /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */ Use var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */ Using editor indentation settings to determine formatting styleTo stop using the formatting style defined in the var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 config file regarding indentation size and whether or not to use tabs or spaces, in order to use sublime's settings instead, then set the Sublime-HTMLPrettify 0 setting to var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */1 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. Using editor syntax for determining file typeTo stop using editor syntax and instead use file extensions for determining file type, set the { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }8 setting to { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }9 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. These configuration files can be placed wherever a var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 could. To stop respecting Sublime-HTMLPrettify 7 files, which override the prettifier's rules, set the Sublime-HTMLPrettify 8 setting to { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } }9 in /* beautify preserve:start */ { browserName: 'internet explorer', platform: 'Windows 7', version: '8' } /* beautify preserve:end */0. Note that { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } }8 and Sublime-HTMLPrettify 0 have precedence and will always override any other settings from any configuration file like var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 and Sublime-HTMLPrettify 7.Using your own .jsbeautifyrc optionsThe plugin looks for a var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 file in the following directories:
When one is found, it stops searching, and it uses those options along with the default ones. { // The plugin looks for a .jsbeautifyrc file in the same directory as the // source file you're prettifying (or any directory above if it doesn't exist, // or in your home folder if everything else fails) and uses those options // along the default ones. // Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options // Documentation: https://github.com/beautify-web/js-beautify "all": { // These rules apply to any supported code that is going to be be prettified, // and have the lowest level of precedence (meaning any of the settings in // the 'html', 'css', 'js', 'json' and 'custom' categories override these). // You can add other .jsbeautifyrc rules in this section too. // End output with newline "end_with_newline": false, // Character(s) to use as line terminators. "eol": "\n", // Initial indentation level "indent_level": 0, // Indentation character "indent_char": " ", // Indentation size "indent_size": 4, // Indent with tabs, overrides `indent_size` and `indent_char` "indent_with_tabs": false, // Maximum number of line breaks to be preserved in one chunk (0 disables) "max_preserve_newlines": 0, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text) "preserve_newlines": true, // Lines should wrap at next opportunity after this number of characters (0 disables) "wrap_line_length": 0 }, "html": { // Rules added here apply only to HTML-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // e.g. {{#foo}}, {{/foo}} "indent_handlebars": false, // Indent and sections "indent_inner_html": false, // [keep|separate|normal] "indent_scripts": "keep", // List of tags that should not be reformatted. This should generally not be needed. "unformatted": [] }, "css": { // Rules added here apply only to CSS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // Add a new line after every css rule "newline_between_rules": true, // Selector separator character "selector_separator": " ", // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br") "selector_separator_newline": true }, "js": { // Rules added here apply only to JS-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "collapse-preserve-inline", // Break chained method calls across subsequent lines "break_chained_methods": false, // Put commas at the beginning of new line instead of end "comma_first": false, // Pass E4X xml literals through untouched "e4x": false, // If true, then jslint-stricter mode is enforced "jslint_happy": false, // Preserve array indentation "keep_array_indentation": false, // Preserve function indentation "keep_function_indentation": false, // [before-newline|after-newline|preserve-newline] Set operator position "operator_position": "before-newline", // Should the space before an anonymous function's parens be added, "function()" vs "function ()" "space_after_anon_function": false, // Should the space before conditional statement be added, "if(true)" vs "if (true)" "space_before_conditional": true, // Add padding spaces within empty paren, "f()" vs "f( )" "space_in_empty_paren": false, // Add padding spaces within paren, ie. f( a, b ) "space_in_paren": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "json": { // Rules added here apply only to JSON-like files, as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over all of the settings in the 'all' category above. // You can add other .jsbeautifyrc rules in this section too. // [collapse|collapse-preserve-inline|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or put end braces on own line, or attempt to keep them where they are "brace_style": "expand", // Preserve array indentation "keep_array_indentation": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65" "unescape_strings": false }, "custom": { // Rules added here apply only to files matching specific glob strings, // but respecting any whitelists or blacklists as determined by the // rules specified for `global_file_rules` in the plugin settings. They // take precedence over any of the settings in the categories above. // For the following entries, keys are globs and values are objects which // can contain any kind of .jsbeautifyrc setting. "package?(-lock).json": { "indent_size": 2, "brace_style": "collapse" }, "*.sublime-@(settings|keymap|commands|menu)": { "indent_size": 4, "brace_style": "expand" } } } And here's how a var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 file in your home folder could look like: { "html": { "indent_char": "\t", "indent_size": 1 }, "js": { "indent_char": " ", "indent_size": 2 } } See documentation for , or . A few persistent options are always applied from a var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 file located in the same directory as the plugin, if not overwritten by your own var a = 1; /* beautify ignore:start */ {This is some strange{template language{using open-braces? /* beautify ignore:end */2 file. Those are defined here. You can safely add stuff to that json file if you want: |