I use vim
for much of my text editing and sometimes want/need to format a copied (JSON but in plain unformatted) text string as JSON in vim
.
Below is a quick guide to do doing so directly in vim
and then adding it to your .vimrc
configuration file for quick access.
Guide
In vim
(normal mode) you can simply do:
:%!python -m json.tool
Adding as a command in .vimrc
You can add the following to your ~/.vimrc
configuration file:
com! Jsonify %!python -m json.tool
To use this command in vim
(normal mode), do:
:Jsonify
References
Related articles