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
Computational statisticiansData scientists have some the funnest tools, and I found a good 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 http://stedolan.github.io/jq/download/linux64/jq -o ~/bin/jq
chmod +x ~/bin/jq
In vim, open your unformatted JSON file, then:
There you go, ladies and gents — a command so short, you don’t even need to put it in your vimrc!