Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
I use json.tool a lot to format JSON directly in vim. Simply highlight the text you want to format and run :!python3 -m json.tool. There are probably plugins to do this too, but doing it this way is probably the simplest, unless vim has a built-in for it.
Yeah, I knew someone was going to say that. Usually it’s more likely that Python is installed than jq - especially on servers. But yes, that would definitely work too.
Sure, I’m just not sure when I’d ever run into that. Either I’m doing it a lot and installing jq is reasonable, or I’m not allowed on the server anyway and need to copy/paste from logs.
I used to use python -m json.tool a lot, but I haven’t needed to in many years.
I use
json.tool
a lot to format JSON directly in vim. Simply highlight the text you want to format and run:!python3 -m json.tool
. There are probably plugins to do this too, but doing it this way is probably the simplest, unless vim has a built-in for it.Could probably do the same with
:! jq .
It’s a bit shorter.Yeah, I knew someone was going to say that. Usually it’s more likely that Python is installed than jq - especially on servers. But yes, that would definitely work too.
Sure, I’m just not sure when I’d ever run into that. Either I’m doing it a lot and installing
jq
is reasonable, or I’m not allowed on the server anyway and need to copy/paste from logs.I used to use
python -m json.tool
a lot, but I haven’t needed to in many years.