tpfysw
Last Updated: February 25, 2016
·
3.36K
· sickill
Sickill avatar 2016 bw

Pretty format JSON in Vim

Vim lets you set equalprg option for each filetype. From Vim docs:

External program to use for "=" command. When this option is empty the internal formatting functions are used; either 'lisp', 'cindent' or 'indentexpr'. When Vim was compiled without internal formatting, the "indent" program is used. ...

Add following line to you .vimrc:

au FileType json setlocal equalprg=python\ -m\ json.tool

Now, to pretty format your JSON just type gg=G.

Say Thanks
Respond

1 Response
Add your response

6115
2aca501921a5a98762cc4af16da258b8

That's great, thanks!

over 1 year ago ·
Filed Under