How to auto format JSON on save in Vim
If you are keen on using external tool and you are doing some work with json, I would suggest using the jq
:
https://stedolan.github.io/jq/
Then, you can execute :%!jq .
inside vim which will replace the current buffer with the output of jq.
In one command, try this:
execute '%!python -m json.tool' | w
You could then add you own key binding to make it a simpler keystroke. Of course, for this to work, you need to have Python installed on your machine.