Pretty Json & Vim
So of late I’ve taken to using vim as my main IDE, yes I know it’s not technically an IDE but you can damn well make it one with a few plugins, and I’ve been dealing with python a lot of recent weeks to rebuild a discord bot that I’ve laying around. With the work in python I’ve had to deal with json files on and off to grab from other APIs and one thing vim doesn’t do pretty… json.
So, if you’ve ever loaded up a json file in vim before you’ll know that it just spews forth barely readable lines of text with no formatting at all, how do we make it readable? Easy
:!python -m json.tool
That’s it! It makes vim call up python and run -m json.tool. This makes vim print out json pretty and readable.
Edit: As an aside you can make python print pretty in the terminal by using the pprint command (yes, two p’s).