Pretty-print JSON in vim

TL;DR A quick way to pretty-print JSON in vim with no dependencies (here's looking at you, Perl). Download jq then :%!jq '.'

Computational statisticiansData scientists have some the most fun tools, and I found an excellent write-up of a few more I didn't know about called 7 command-line tools for data science. The first thing the article mentions is a gem called jq.

I found jq to be especially useful for formatting JSON in vim. So, before ado can in any way be furthered:

curl -o ~/bin/jq
chmod +x ~/bin/jq

In vim, open your unformatted JSON file, then

:%!jq '.'

There you go, ladies and gents — a command so short, you don't even need to put it in your .vimrc!