Last active
September 18, 2017 12:27
-
-
Save zinovyev/c4b6ec3c24670278adfebfb9ecced84b to your computer and use it in GitHub Desktop.
Format JSON in VIM through a filter on Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Format JSON | |
function JsonFormat() | |
execute(':%! ruby -rjson -e "print JSON.pretty_generate(JSON.parse(ARGF.read))"') | |
endfunction | |
command JsonFormat call JsonFormat() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put it to your
.vimrc
file.Type:
:JsonFormat
to format a currently opened.json
file.