Skip to content

Instantly share code, notes, and snippets.

@datacustodian
Last active January 24, 2019 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datacustodian/ae5558681ba574ff3ef287a59b5ad914 to your computer and use it in GitHub Desktop.
Save datacustodian/ae5558681ba574ff3ef287a59b5ad914 to your computer and use it in GitHub Desktop.
Pretty Print JSON in Vim

Pretty Print JSON in Vim

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment