In VIm, is there a way to print a JSON snipped inside a file in the "pretty" format?
For example, having the following file
# a comment
def my_func():
    pass
{"bla": [1, 2, 3], "yes": false}  # <--- pretty print this
# another comment
<foo>why do I mix everything in one file?</foo>
<bar>it's an example, dude</bar>
I would like to change the marked line to
{
   "bla":[
      1,
      2,
      3
   ],
   "yes":false
}
I'm looking for something like :%!python -m json.tool but only for the selected lines.
Specifying the line number should work. For example:
:5!python -m json.tool
Or if it takes multiple lines:
:4,6!python -m json.tool
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With