Matt Seymour

When trying to format json in vim you can use the following command which makes use of the python json.tool

:%!python -m json.tool

Here is an example of the command at work

1 {
2     "name": "my-project-name",
3   "version": "0.1.0",
4     "devDependencies": {
5             "grunt": "~0.4.5",
6                 "grunt-contrib-jshint": "~0.10.0",
7                 "grunt-contrib-watch":"~1.0.0"
8                           }
9                           }


:%!python -m json.tool



> Output
1 {
2     "devDependencies": {
3         "grunt": "~0.4.5",
4         "grunt-contrib-jshint": "~0.10.0",
5         "grunt-contrib-watch": "~1.0.0"
6     },
7     "name": "my-project-name",
8     "version": "0.1.0"
9 }