Skip to content

Instantly share code, notes, and snippets.

@zinovyev
Last active September 18, 2017 12:27
Show Gist options
  • Save zinovyev/c4b6ec3c24670278adfebfb9ecced84b to your computer and use it in GitHub Desktop.
Save zinovyev/c4b6ec3c24670278adfebfb9ecced84b to your computer and use it in GitHub Desktop.
Format JSON in VIM through a filter on Ruby
" Format JSON
function JsonFormat()
execute(':%! ruby -rjson -e "print JSON.pretty_generate(JSON.parse(ARGF.read))"')
endfunction
command JsonFormat call JsonFormat()
@zinovyev
Copy link
Author

Put it to your .vimrc file.
Type: :JsonFormat to format a currently opened .json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment