For sublime 4 below work for me on MAC OS :
Install "Pretty JSON" sublime 4 by referring below:
- Use key combination Cmd + Shift + p and type Install Package
- Select Package Control: Install Package from the search results
- Type Pretty JSON and select it from the search results
OR use "Manual Installation" steps of below link
https://packagecontrol.io/packages/Pretty%20JSON
now for shortcut :
Click on Sublime -> Preferences -> Key Bindings
Here add the below json part inside existing json and save the file
{ "keys": [ "ctrl+shift+j" ], "command": "pretty_json" }
you can use cmd too instead of ctrl, set says as per your preference
Complete json will look like below:
[{
"keys": [
"command+l"
],
"command": "reindent"
},
{
"keys": [
"ctrl+shift+s"
],
"command": "auto_save"
},
{
"keys": [
"ctrl+shift+k"
],
"command": "js_format"
},
{
"keys": [
"ctrl+shift+j"
],
"command": "pretty_json"
}
]
Now use below short key anytime to beautify json on sublime
ctrl+shift+j
You can also use command instead of ctrl
>>> sublime_json_reindent Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'sublime_json_reindent' is not defined
– Rozamond