jsonsublimetext3sublimetext2sublimetextsublimetext4

Sublime Text - JSON formatter shortcut


I'm using SublimeText.

How to reindent Json code with a shortcut?

I've already installed packageControl and it works.

I already tried JsonReindent package but it has not a shortcut by default and i don't know its command name.

I already have this command (from my previous sublimetext2 on another pc, where it works fine):

// JSON reindent
{ "keys": ["ctrl+shift+j", "ctrl+shift+j"], "command": "json_reindent" },

But here it doesn't work.


Solution

  • If you look at the source, the name of the sublime_plugin.TextCommand subclass is SublimeJsonReindentCommand. Per the conventions for command names, the resulting command is named sublime_json_reindent. Simply change your key binding to:

    { "keys": ["ctrl+shift+j", "ctrl+shift+j"], "command": "sublime_json_reindent" },
    

    and you should be all set.