Use sublime jsfmt plug-in in formatted JSX pits. Mdsublime in Sublime
In a JSX file pasted a section of bootstrap in tables code, alignment is very bad, people look very uncomfortable, so in the online search various sublime formatting JSX syntax plug-in
Found two, one is
Jsformat
The other one is
Sublime-jsfmt
1. For Jsformat:
Install, and modify the user-setting to:
{ "e4x": true, //Jsformat options "Format_on_save": true, //{} curly braces no longer force line wrapping "Brace_style": "Collapse-preserve-inline", "Format_selection": false, "Indent_size": 2, "Indent_char": " ", "Indent_with_tabs": false,}
View the Keybindings-default in the configuration file to see the default shortcut keys for formatting alt+ctrl+f ,
Execute this command in a file that you want to format, invalid
2. For sublime jsfmt:
Install, and modify the user-setting to:
{ "Extensions":["JS", "JSX", "Sublime-settings"], "Options": { "Plugins":["ESFORMATTER-JSX",], "JSX": { "FORMATJSX": true, //Change these to your preferred values //Refer to Https://github.com/royriojas/esformatter-jsx#best-configuration for more options "Attrsonsamelineastag": false, "Maxattrsontag": 1, "Firstattributeonsameline": false, "Alignwithfirstattribute": true } //Other Esformatter options } }
and set the shortcut keys in the preferences keybinds:
{"keys": ["ctrl+q"],"command":"format_javascript"},
Then use the shortcut keys in the Jsx file that you need to format
ctrl+qDoes not have any effect.
View [Official Website]:
(HTTPS://GITHUB.COM/IONUTVMI/SUBLIME-JSFMT)
, other people's configuration is like this, looked at several blogs are still this way.
Looks like we didn't see anything wrong.
Until I did a search on Google.
[Help Blog]
(74942422)
Read this blog to know, oh, originally before using sublime jsfmt, but also need to install two plugins:
Esformatter
Esformatter-jsx
When I installed it in the package install, I came across a package message telling me that I needed to use NPM to install
(Actually I don't quite understand why)
NPM install-g Esformatter
NPM install-g ESFORMATTER-JSX
Then restart the sublime, and use it in the Jsx file that needs to be formatted
ctrl+q, the code can be formatted successfully.
At present, the format is not so good-looking, it is estimated that the problem of setup.
In fact, go back to look at Sublime Jsfmt's official website, will find installing plugins this section.
Go and see Esformatter's official website.
Https://github.com/royriojas/esformatter-jsx/wiki/Usage-with-jsfmt
Formatting jsx files in sublime