https://pascalprecht.github.io/posts/pretty-print-json-in-vim/
Create a file name pretty_print_json.vim
with the following content:
:%!python3 -m json.tool
:wq
If you only have Python 2 on your system, then remove the "3" after "python":
:%!python -m json.tool
:wq
WARNING: If you still use Python 2, check out the Python Clock.
To prettify ugly.json
in place:
vim -s pretty_print_json.vim ugly.json
JSON content in ugly.json
is now pretty.